Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
11 kB
7
Indexable
Never
new 
    giveplayeridwm,
    //pricewm,
    //storageidwm,
    stringwm[128],
    x_weapon[20];

new 
    //time
    timekatana = 10,
    timepistol = 30,
    timeshotgun = 50,
    timeuzi = 70,
    timemp5 = 100,
    timem4 = 150,
    nextcrafttime = 20,
    // cost
    c_katana = 1000,
    c_pistol = 3000,
    c_shotgun = 7000,
    c_uzi = 12000,
    c_mp5 = 17000,
    c_m4 = 25000;

stock wepmaking_OnPlayerConn(playerid)
{
    GunOffer[playerid] = INVALID_PLAYER_ID;
	GunStorageID[playerid] = -1;
    GunId[playerid] = 0;
	GunMats[playerid] = 0;
    return 1;
}

stock wepmaking_OnPlayerDisconn(playerid)
{
    DeletePVar(playerid, "TimeMakeGun");

    KillTimer(GetPVarInt(playerid, "TimeMakeKatana"));
    KillTimer(GetPVarInt(playerid, "TimeMakePistol"));
    KillTimer(GetPVarInt(playerid, "TimeMakeShotgun"));
    KillTimer(GetPVarInt(playerid, "TimeMakeUzi"));
    KillTimer(GetPVarInt(playerid, "TimeMakeMP5"));
    KillTimer(GetPVarInt(playerid, "TimeMakeM4"));
    return 1;
}

CMD:sellgun(playerid, params[])
{
	if(HungerPlayerInfo[playerid][hgInEvent] != 0) return SendClientMessageEx(playerid, -1, "Ban khong the lam dieu nay khi dang trong su kien Hunger Games!");
    if(GetPVarInt(playerid, "IsInArena") >= 0) return SendClientMessageEx(playerid,-1, "Ban khong the lam dieu nay khi dang trong arena!");
   	if(GetPVarInt( playerid, "EventToken") != 0) return SendClientMessageEx(playerid, -1, "Ban khong the lam dieu nay khi dang trong su kien.");
    //if (PlayerInfo[playerid][pJob] != 9 && PlayerInfo[playerid][pJob2] != 9) return SendClientMessageEx(playerid,-1,"   Ban khong phai nguoi ban vu khi!");
    //if(PlayerInfo[playerid][pScrewdriver] == 0) return SendClientMessageEx(playerid,-1,"Ban phai la tho thu cong va chiec tua vit de che tao vu khi!");
    if (PlayerInfo[playerid][pJailTime] > 0) return SendClientMessageEx(playerid,-1,"Ban khong the dua sung khi dang trong tu!");
    if(IsPlayerInAnyVehicle(playerid)) return SendClientMessageEx(playerid, -1, "Ban khong the lam dieu nay bay gio.");
    if(PlayerInfo[playerid][pHospital] > 0) return SendClientMessageEx(playerid, -1, "Ban khong the tao vu khi khi dang o benh vien.");
    if (GetPVarInt(playerid, "ArmsTimer") > 0) 
    {
        format(stringwm, sizeof(stringwm), "Ban phai doi %d giay truoc khi dua vu khi cho nguoi  khac.", GetPVarInt(playerid, "ArmsTimer"));
        SendClientMessageEx(playerid,-1,stringwm);
        return 1;
    }


    if(sscanf(params, "us[20]", giveplayeridwm, x_weapon)) 
    {
        new levelwm = PlayerInfo[playerid][pArmsSkill];
        SendClientMessageEx(playerid, COLOR_GREEN, "________________________________________________");
        SendClientMessageEx(playerid, COLOR_YELLOW, "<< Danh sach vu khi (Vat Lieu) >>");
        if(levelwm >= 0 && levelwm <= 20) {
            SendClientMessageEx(playerid, COLOR_GRAD1, "|Katana(1k)");
        }
        else if(levelwm >= 21 && levelwm <= 70) {
            SendClientMessageEx(playerid, COLOR_GRAD1, "|Katana(1k)");
            SendClientMessageEx(playerid, COLOR_GRAD1, "|Pistol(3k)");
        }
        else if(levelwm >= 71 && levelwm <= 140) {
            SendClientMessageEx(playerid, COLOR_GRAD1, "|Katana(1k)");
            SendClientMessageEx(playerid, COLOR_GRAD1, "|Pistol(1k) |Shotgun(7k)");
        }
        else if(levelwm >= 141 && levelwm <= 240) {
            SendClientMessageEx(playerid, COLOR_GRAD1, "|Katana(1k)");
            SendClientMessageEx(playerid, COLOR_GRAD1, "|Pistol(1k) |Shotgun(7k)");
            SendClientMessageEx(playerid, COLOR_GRAD1, "|UZI(12k)");
        }
        else if(levelwm >= 241 && levelwm <= 390) {
            SendClientMessageEx(playerid, COLOR_GRAD1, "|Katana(1k)");
            SendClientMessageEx(playerid, COLOR_GRAD1, "|Pistol(1k) |Shotgun(7k)");
            SendClientMessageEx(playerid, COLOR_GRAD1, "|UZI(12k)   |MP5(17k)");
        }
        else if(levelwm >= 391)
        {
            SendClientMessageEx(playerid, COLOR_GRAD1, "|Katana(1k)");
            SendClientMessageEx(playerid, COLOR_GRAD1, "|Pistol(1k) |Shotgun(7k)");
            SendClientMessageEx(playerid, COLOR_GRAD1, "|UZI(12k)   |MP5(17k)");
            SendClientMessageEx(playerid, COLOR_GRAD1, "|M4(25k)");
        }
        SendClientMessageEx(playerid, COLOR_GREEN, "________________________________________________");
        SendClientMessageEx(playerid, COLOR_GREY, "SU DUNG: /banvukhi [nguoi choi] [ten vu khi]");
        return 1;
    }

	if(!IsPlayerConnected(giveplayeridwm)) {
		return SendClientMessageEx(playerid, COLOR_GRAD2, "Nguoi choi khong hop le.");
	}
	if(HungerPlayerInfo[giveplayeridwm][hgInEvent] != 0) return SendClientMessageEx(playerid, COLOR_GREY, "   Nguoi do khong the nhan vu khi vao luc nay.");
    
    if(!ProxDetectorS(5.0, playerid, giveplayeridwm))
        return SendClientMessageEx(playerid, -1, "Nguoi do khong o gan ban.");
    /* if(strcmp(x_weapon,"katana",true) == 0) 
    {
        if(PlayerInfo[playerid][pMats] < c_katana) 
            return SendClientMessageEx(playerid, -1 ,"Ban khong du vat lieu.");
        TogglePlayerControllable(playerid, 0);
		SetPVarInt(playerid, "IsFrozen", 1);
        PlayerInfo[playerid][pMats] -= c_katana;
        SetPVarInt(playerid, "TimeMakeGun", timekatana);
		SetTimerEx("TimeMakeKatana", timekatana*100, 0, "d", playerid);
        GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~r~DANG CHE TAO", 1000, 3);
	    ApplyAnimation(playerid, "BD_FIRE", "wash_up", 4.0, 1, 0, 0, 0, 0, 1);
    }
    else if(strcmp(x_weapon,"pistol",true) == 0) 
    {
        if(PlayerInfo[playerid][pMats] < c_pistol) 
            return SendClientMessageEx(playerid, -1 ,"Ban khong du vat lieu.");
        TogglePlayerControllable(playerid, 0);
		SetPVarInt(playerid, "IsFrozen", 1);
        PlayerInfo[playerid][pMats] -= c_pistol;
        SetPVarInt(playerid, "TimeMakeGun", timepistol);
		SetTimerEx("TimeMakePistol", timepistol*100, 0, "d", playerid);
        GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~r~DANG CHE TAO", 1000, 3);
	    ApplyAnimation(playerid, "BD_FIRE", "wash_up", 4.0, 1, 0, 0, 0, 0, 1);
    }
    else if(strcmp(x_weapon,"mp5",true) == 0) 
    {
        if(PlayerInfo[playerid][pMats] < c_mp5) 
            return SendClientMessageEx(playerid, -1 ,"Ban khong du vat lieu.");
        TogglePlayerControllable(playerid, 0);
		SetPVarInt(playerid, "IsFrozen", 1);
        PlayerInfo[playerid][pMats] -= c_mp5;
        SetPVarInt(playerid, "TimeMakeGun", timemp5);
		SetTimerEx("TimeMakeMP5", timemp5*100, 0, "d", playerid);
        GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~r~DANG CHE TAO", 1000, 3);
	    ApplyAnimation(playerid, "BD_FIRE", "wash_up", 4.0, 1, 0, 0, 0, 0, 1);
    }
    else if(strcmp(x_weapon,"uzi",true) == 0) 
    {
        if(PlayerInfo[playerid][pMats] < c_uzi) 
            return SendClientMessageEx(playerid, -1 ,"Ban khong du vat lieu.");
        TogglePlayerControllable(playerid, 0);
		SetPVarInt(playerid, "IsFrozen", 1);
        PlayerInfo[playerid][pMats] -= c_uzi;
        SetPVarInt(playerid, "TimeMakeGun", timeuzi);
		SetTimerEx("TimeMakeUzi", timeuzi*100, 0, "d", playerid);
        GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~r~DANG CHE TAO", 1000, 3);
	    ApplyAnimation(playerid, "BD_FIRE", "wash_up", 4.0, 1, 0, 0, 0, 0, 1);
    }
    else if(strcmp(x_weapon,"shotgun",true) == 0) 
    {
        if(PlayerInfo[playerid][pMats] < c_shotgun) 
            return SendClientMessageEx(playerid, -1 ,"Ban khong du vat lieu.");
        TogglePlayerControllable(playerid, 0);
		SetPVarInt(playerid, "IsFrozen", 1);
        PlayerInfo[playerid][pMats] -= c_shotgun;
        SetPVarInt(playerid, "TimeMakeGun", timeshotgun);
		SetTimerEx("TimeMakeShotgun", timeshotgun*100, 0, "d", playerid);
        GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~r~DANG CHE TAO", 1000, 3);
	    ApplyAnimation(playerid, "BD_FIRE", "wash_up", 4.0, 1, 0, 0, 0, 0, 1);
    } */
    else if(strcmp(x_weapon,"m4",true) == 0) 
    {
        if(PlayerInfo[playerid][pMats] < c_m4) 
            return SendClientMessageEx(playerid, -1 ,"Ban khong du vat lieu.");
        if(PlayerInfo[giveplayeridwm][pMats] < c_m4) 
            return SendClientMessageEx(playerid, -1 ,"Nguoi do khong du vat lieu.");
        /* if(GetPVarInt(playerid, "TimeMakeGun") != 0)
            return SendClientMessageEx(playerid, -1, "Ban hien dang che tao sung roi."); */
        TogglePlayerControllable(playerid, 0);
		SetPVarInt(playerid, "IsFrozen", 1);
        PlayerInfo[playerid][pMats] -= c_m4;
        //

        SetPVarInt(playerid, "TimeMakeM4", timem4);
        GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~r~DANG CHE TAO", timem4*1000, 3);
        format(stringwm, sizeof(stringwm), "Dang che tao M4 cho %s. Hay cho trong giay lat...", GetPlayerNameEx(giveplayeridwm));
        SendClientMessageEx(playerid, COLOR_LIGHTBLUE, stringwm);
    }
    else return SendClientMessageEx(playerid, COLOR_GREY, "Ten vu khi khong hop le !");

	return 1;
}

forward TimeMakeM4(playerid);
public TimeMakeM4(playerid)
{
    if(giveplayeridwm == playerid) 
    {
        TogglePlayerControllable(playerid, 0);
		DeletePVar(playerid, "IsFrozen");
        SendClientMessageEx(playerid, -1, "Ban da tao cho minh mot cay M4");
        format(stringwm, sizeof(stringwm), "* %s da tao mot vu khi tu vat lieu cua minh.", GetPlayerNameEx(playerid));
        ProxDetector(30.0, playerid, stringwm, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        PlayerInfo[playerid][pMats] -= c_m4;
        GivePlayerValidWeapon(playerid, 31, 60000);
        PlayerInfo[playerid][pArmsSkill]++;
        SetPVarInt(playerid, "ArmsTimer", nextcrafttime); SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_ARMSTIMER);
        if(PlayerInfo[playerid][pArmsSkill] == 70)
            SendClientMessageEx(playerid, COLOR_YELLOW, "* Ky nang che tao vu khi cua ban dat cap do 2, se co them nhieu loai vu khi de ban.");
        else if(PlayerInfo[playerid][pArmsSkill] == 140)
            SendClientMessageEx(playerid, COLOR_YELLOW, "* Ky nang che tao vu khi cua ban dat cap do 3, se co them nhieu loai vu khi de ban.");
        else if(PlayerInfo[playerid][pArmsSkill] == 240)
            SendClientMessageEx(playerid, COLOR_YELLOW, "* Ky nang che tao vu khi cua ban dat cap do 4, se co them nhieu loai vu khi de ban.");
        else if(PlayerInfo[playerid][pArmsSkill] == 390)
            SendClientMessageEx(playerid, COLOR_YELLOW, "* Ky nang che tao vu khi cua ban dat cap do 5, se co them nhieu loai vu khi de ban.");
        else if(PlayerInfo[playerid][pArmsSkill] >= 391)
            SendClientMessageEx(playerid, COLOR_YELLOW, "* Ky nang che tao vu khi cua ban dat cap do 6.");
        return 1;
    }
    PlayerInfo[giveplayeridwm][pMats] -= c_m4;
    GivePlayerValidWeapon(giveplayeridwm, 31, 60000);
    format(stringwm, sizeof(stringwm), "Nguoi choi: %s da che tao thanh cong khau M4 va dua no cho ban.", GetPlayerNameEx(playerid));
    ShowPlayerDialog(playerid, DIALOG_NOTHING, DIALOG_STYLE_MSGBOX, "THONG BAO", stringwm, "Dong", "");
    return 1;
}