SA-MP Forums Archive
[HELP]Key Code not working[HELP]!!! - 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: [HELP]Key Code not working[HELP]!!! (/showthread.php?tid=369805)



[HELP]Key Code not working[HELP]!!! - Cjgogo - 18.08.2012

OK,so,basically I've got timed out from my server(I was in a car,with my friend as passenger),and by reflex(he plays BF3) he pressed F1 to switch to driver's seat,so I got the idea to script it,yet,obviusly,as F1 is an assigned key in SAMP,I used SPACE.So when a player wich is passenger in a car with no driver presses SPACE,he should be moved to driver's seat,yet,even if the code returns no errors,it doesn't work:

pawn Код:
new vehicleid=GetPlayerVehicleID(playerid);
if(newkeys & KEY_JUMP)
    {
       if(GetPVarInt(playerid,"Adminlevel") != 0)
       {
          if(IsPlayerInAnyVehicle(playerid))
          {
             if(GetPlayerState(playerid)==PLAYER_STATE_PASSENGER)
             {
                new OK=1;
                for(new i=0;i<MAX_PLAYERS;i++)
                {
                    if(IsPlayerInAnyVehicle(i))
                    {
                       if(GetPlayerVehicleID(i)==GetPlayerVehicleID(playerid))
                       {
                           if(GetPlayerState(i)==PLAYER_STATE_DRIVER)
                           {
                               OK=0;
                               break;
                           }
                       }
                    }
                 }
                 if(OK==1)
                 {
                    PutPlayerInVehicle(playerid,vehicleid,0);
                    SendClientMessage(playerid,COLOR_GREEN,"Succesfully transfered to driver's seat!");
                 }
                 else
                 {
                    SendClientMessage(playerid,COLOR_RED,"This vehicle is ocuppied(it has a driver)!");
                 }
              }
            }
        }
      }
So,what's worng?Thanks in advance.