SA-MP Forums Archive
Whats wrong with the code? - 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: Whats wrong with the code? (/showthread.php?tid=187804)



Whats wrong with the code? - audifan00 - 04.11.2010

hello guys, i made a code to prevent some vehicles from use...
It dosn't give me any errors or warnings, simply it just dont work in game.

Here is the code help plox :/

Quote:

public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
if(GetPlayerVehicleID(playerid) == 541)
{
if(GetPlayerTeam(playerid) == 2)
{
SendClientMessage(playerid, COLOR_WHITE,"VIP: Premium vehicle entered");
}
else
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, 0x24FF0AB9,"VIP: YOU ARE NOT VIP!");
}
if(newstate == PLAYER_STATE_DRIVER)
{
if(GetPlayerVehicleID(playerid) == 432)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED,"NO TANKS ALLOWED!");
}
if(GetPlayerVehicleID(playerid) == 425)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_RED,"NO HUNTERS ALLOWED!");
}
}
}
}
return 1;
}




Re: Whats wrong with the code? - (SF)Noobanatior - 04.11.2010

PHP код:
public OnPlayerStateChange(playeridnewstateoldstate){
    if(
newstate == PLAYER_STATE_DRIVER){
        if(
GetVehicleModel(GetPlayerVehicleID(playerid)) == 541){
            if(
GetPlayerTeam(playerid) == 2){
                
SendClientMessage(playeridCOLOR_WHITE,"VIP: Premium vehicle entered");
            }
            else{
                
RemovePlayerFromVehicle(playerid);
                
SendClientMessage(playerid0x24FF0AB9,"VIP: YOU ARE NOT VIP!");
            }
            if(
GetVehicleModel(GetPlayerVehicleID(playerid)) == 432){
                
RemovePlayerFromVehicle(playerid);
                
SendClientMessage(playeridCOLOR_RED,"NO TANKS ALLOWED!");
            }
            if(
GetVehicleModel(GetPlayerVehicleID(playerid)) == 425){
                
RemovePlayerFromVehicle(playerid);
                
SendClientMessage(playeridCOLOR_RED,"NO HUNTERS ALLOWED!");
            }
        }
    }
    return 
1;

this should work


Re: Whats wrong with the code? - Hal - 04.11.2010

Quote:
Originally Posted by audifan00
Посмотреть сообщение
hello guys, i made a code to prevent some vehicles from use...
It dosn't give me any errors or warnings, simply it just dont work in game.

Here is the code help plox :/
Now, im going to tell you what you did wrong, so you can learn not just be given code.

You used GetVehicleID, where it should be GetVehicleModel which gets the model id. VehicleID is the id of the vehicle Ig, has nothing to do with the model.


Re: Whats wrong with the code? - audifan00 - 05.11.2010

thanks guys i got it D:

some wonderful helpers out there!

thanks again i will try it when i will be on ma pc