Whats wrong with the code?
#1

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;
}

Reply
#2

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
Reply
#3

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.
Reply
#4

thanks guys i got it D:

some wonderful helpers out there!

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


Forum Jump:


Users browsing this thread: 1 Guest(s)