Problem with GetPlayerWeaponData
#1

Hello . I want that when the player makes a command , it give him a weapon . But I want the weapon that had previously be saved because when the player redo the command ,he get back to him.

pawn Код:
CMD:weap(playerid, params[])
{
    new Weap[2];

    new Pick[MAX_PLAYERS];

    if(Pick[playerid] == 0)
    {
        Pick[playerid] = 1;
        GetPlayerWeaponData(playerid, 2, Weap[0], Weap[1]);
        SendClientMessageEx(playerid, -1, "Message.");
        GivePlayerWeapon(playerid, 23, cellmax);
        SetPlayerArmedWeapon(playerid, 23);
    }
    else if(Pick[playerid] == 1)
    {
        Pick[playerid] = 0;
        SetPlayerAmmo(playerid, 23, 0);
        GivePlayerWeapon(playerid, Weap[0], Weap[1]);
        SendClientMessageEx(playerid, -1, "Message.");
    }
    return 1;
}
This is my code but the weapon will not given back.

Can you help me? Thank you!
Reply
#2

what command process are you using?
Reply
#3

ZCMD.

CMD:command(playerid, params[])
Reply
#4

pawn Код:
new gPlayerWeapons[MAX_PLAYERS][13][2];

public OnPlayerDeath(playerid, killerid, reason)
{
    for(new i = 0; i <= 12; i++)
    {
        GetPlayerWeaponData(playerid, i, gPlayerWeapons[playerid][i][0], gPlayerWeapons[playerid][i][1]);
    }
    return 1;
}

CMD:weap(playerid, params[])
{
    new Weap[2];

    new Pick[MAX_PLAYERS];

    if(Pick[playerid] == 0)
    {
        Pick[playerid] = 1;
        GetPlayerWeaponData(playerid, 2, Weap[0], Weap[1]);
        SendClientMessageEx(playerid, -1, "Message.");
        GivePlayerWeapon(playerid, 23, cellmax);
        SetPlayerArmedWeapon(playerid, 23);
       
        // giving him his old weapons
        for(new i = 0; i <= 12; i++)
        {
            GivePlayerWeapon(playerid, gPlayerWeapons[playerid][i][0], gPlayerWeapons[playerid][i][1]);
        }
    }
    else if(Pick[playerid] == 1)
    {
        Pick[playerid] = 0;
        SetPlayerAmmo(playerid, 23, 0);
        GivePlayerWeapon(playerid, Weap[0], Weap[1]);
        SendClientMessageEx(playerid, -1, "Message.");
    }
    return 1;
}
Reply
#5

Why this code? I want to give weapon if the Pick[playerid] is 1 and OnPlayerDeath isn't called.

The slot that I want is 2 (PISTOL)... Thank you but isn't that I want. Another reply, please?
Reply
#6

Put Pick[MAX_PLAYERS]; outside the command.
PHP код:
new Pick[MAX_PLAYERS];
CMD:weap(playeridparams[])
{
    new 
Weap[2];
    if(
Pick[playerid] == 0)
    {
        
Pick[playerid] = 1;
        
GetPlayerWeaponData(playerid2Weap[0], Weap[1]);
        
SendClientMessageEx(playerid, -1"Message.");
        
GivePlayerWeapon(playerid23cellmax);
        
SetPlayerArmedWeapon(playerid23);
    }
    else if(
Pick[playerid] == 1)
    {
        
Pick[playerid] = 0;
        
SetPlayerAmmo(playerid230);
        
GivePlayerWeapon(playeridWeap[0], Weap[1]);
        
SendClientMessageEx(playerid, -1"Message.");
    }
    return 
1;

Reply
#7

Thank you but it is outside, in the script I show him for not reading " You don't put Pick[MAX_PLAYERS] "
Reply
#8

So? How can I do?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)