SA-MP Forums Archive
Quick and Easy Question - 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: Quick and Easy Question (/showthread.php?tid=348871)



Quick and Easy Question - olbeercan - 07.06.2012

Well, I haven't been into scripting for a while..
But I was wondering how to fix it so you can't shoot a SPAS or AK47 as a passanger in a Car.

I still want it so they can shoot an MP5 though.. Thanks.


Re: Quick and Easy Question - Kindred - 07.06.2012

You could probably use GetPlayerWeapon on OnPlayerEnterVehicle and then switch there current weapon to there fists or something.

Haven't done this ever, could probably search, I bet a ton of people have done this before.


Re: Quick and Easy Question - zDevon - 07.06.2012

Could try this
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        new Weap[2];
        GetPlayerWeaponData(playerid, 4, Weap[0], Weap[1]); // Get the players SMG weapon in slot 4
        SetPlayerArmedWeapon(playerid, Weap[0]); // Set the player to driveby with SMG
    }
    return 1;
}



Re: Quick and Easy Question - ReneG - 07.06.2012

Don't use OnPlayerEnterVehicle for code like this.

OnPlayerEnterVehicle gets called as soon as the player presses the 'enter' key. Thus making it useless.


Re: Quick and Easy Question - mati233 - 07.06.2012

PHP код:
public OnPlayerStateChange(playeridnewstateoldstate){
   if(
oldstate==PLAYER_STATE_ONFOOT &&  newstate==PLAYER_STATE_PASSENGER){
      if(
GetPlayerWeapon(playerid)==26 || GetPlayerWeapon(playerid)==30){
         
SetPlayerArmedWeapon(playerid,0);
      }
   }