SA-MP Forums Archive
Problem with GetPlayerWeaponData - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with GetPlayerWeaponData (/showthread.php?tid=570082)



Problem with GetPlayerWeaponData - DarkLouis - 05.04.2015

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!


Re: Problem with GetPlayerWeaponData - MotherDucker - 05.04.2015

what command process are you using?


Re: Problem with GetPlayerWeaponData - DarkLouis - 05.04.2015

ZCMD.

CMD:command(playerid, params[])


Re: Problem with GetPlayerWeaponData - Affan - 05.04.2015

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;
}



Re: Problem with GetPlayerWeaponData - DarkLouis - 05.04.2015

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?


Re: Problem with GetPlayerWeaponData - ATGOggy - 05.04.2015

Put Pick[MAX_PLAYERS]; outside the command.
PHP код:
new Pick[MAX_PLAYERS];
CMD:weap(playerid, params[])
{
    new 
Weap[2];
    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;
} 



Re: Problem with GetPlayerWeaponData - DarkLouis - 05.04.2015

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


Re: Problem with GetPlayerWeaponData - DarkLouis - 06.04.2015

So? How can I do?