SA-MP Forums Archive
SetPlayerAmmo - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: SetPlayerAmmo (/showthread.php?tid=248099)



SetPlayerAmmo - Lars_Frederiksen - 12.04.2011

Well I want it to set the players ammo to -20 when they get in the car, but whenever I use this function. It does nothing at all. Does anyone know a way to make it so I can set the players ammo to -20 while being the driver of the car?


Re: SetPlayerAmmo - Calgon - 12.04.2011

I'm pretty sure none of the weapon functions except SetPlayerArmedWeapon() work if a player is in a vehicle.

You can set their weapon to 0 (fists) instead, using SetPlayerArmedWeapon().


Re: SetPlayerAmmo - Kwarde - 12.04.2011

Why do you want that? - So that he can't shoot? Just do this:

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        SetPVarInt(playerid, "OldWep", GetPlayerWeapon(playerid);
        SetPlayerArmedWeaopn(playerid, 0);
    }
    else if(oldstate == PLAYER_STATE_DRIVER)
    {
        SetPlayerArmedWeapon(playerid, GetPVarInt(playerid, "OldWep"));
        DeletePVar(playerid, "OldWep");
    }
    return 1;
}
It set's player weapon to "fist" when he enters a vehicle AS A DRIVER and it changed back to what he has when he exits it (after being the driver).

EDIT: Calg00ne was faster -.-


Re: SetPlayerAmmo - AK47317 - 12.04.2011

Quote:
Originally Posted by Kwarde
Посмотреть сообщение
Why do you want that? - So that he can't shoot? Just do this:

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        SetPVarInt(playerid, "OldWep", GetPlayerWeapon(playerid);
        SetPlayerArmedWeaopn(playerid, 0);
    }
    else if(oldstate == PLAYER_STATE_DRIVER)
    {
        SetPlayerArmedWeapon(playerid, GetPVarInt(playerid, "OldWep"));
        DeletePVar(playerid, "OldWep");
    }
    return 1;
}
It set's player weapon to "fist" when he enters a vehicle AS A DRIVER and it changed back to what he has when he exits it (after being the driver).

EDIT: Calg00ne was faster -.-
pawn Код:
SetPlayerArmedWeaopn(playerid, 0);
make it as

pawn Код:
SetPlayerArmedWeapon ( playerid , 0 ) ;



Re: SetPlayerAmmo - Vince - 12.04.2011

Uh? Both statements are exactly the same. There's absolutely no need for all the additional spaces.


Re: SetPlayerAmmo - Calgon - 12.04.2011

Quote:
Originally Posted by Vince
Посмотреть сообщение
Uh? Both statements are exactly the same. There's absolutely no need for all the additional spaces.
Notice the original says 'Weaopn' instead of 'Weapon', but the additional spacing is just excessive and looks horrid.