SA-MP Forums Archive
anti drive by thing - 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: anti drive by thing (/showthread.php?tid=182006)



anti drive by thing - nejc001 - 08.10.2010

Can you make that when you enter a vehicle as driver your armed weapon changes to fists/hand?


Re: anti drive by thing - Jeffry - 08.10.2010

Will only work if you reset the players weapons, save them, and give them back when he leaves the car.


Re: anti drive by thing - nejc001 - 09.10.2010

Though so. :/


Re: anti drive by thing - Jeffry - 09.10.2010

Okey, I made the code for you. Was easier that I thought.

pawn Код:
new PlayerWeaponDetails[MAX_PLAYERS][13][2];
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER /*|| newstate == PLAYER_STATE_PASSENGER*/) //Just remove the ''/*'' ''*/'' and it works for Passenger too.
    {
        for (new i = 0; i < 13; i++) PlayerWeaponDetails[playerid][i][0]=0, PlayerWeaponDetails[playerid][i][1]=0;
        for (new i = 0; i < 13; i++) GetPlayerWeaponData(playerid, i, PlayerWeaponDetails[playerid][i][0], PlayerWeaponDetails[playerid][i][1]);
        ResetPlayerWeapons(playerid);
    }
    if(oldstate == PLAYER_STATE_DRIVER /*|| newstate == PLAYER_STATE_PASSENGER*/) //Same here.
    {
        if(newstate == PLAYER_STATE_ONFOOT)
        {
            for (new i = 0; i < 13; i++) GivePlayerWeapon(playerid, PlayerWeaponDetails[playerid][i][0], PlayerWeaponDetails[playerid][i][1]);
        }
    }
    return 1;
}
Note: I've tested the code, and the weapon ammo is not always correct. I think that there is a mistake in the function "GetPlayerWeaponData".

Just test the code yourself, and give me your opinion.

Greetz.


Re: anti drive by thing - nejc001 - 10.10.2010

Works awesome, i didnt detect any bugs.
TNX


Re: anti drive by thing - Jeffry - 11.10.2010

Great. Have fun. And Thank you for the feedback.