SA-MP Forums Archive
Only police can enter vehicle - 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: Only police can enter vehicle (/showthread.php?tid=591268)



Only police can enter vehicle - N0FeaR - 10.10.2015

I trying to make a system so only cops can enter their vehicle, but the others team can still enter it.

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new newcar;
    if(CopCar(newcar))
    {
        if (gTeam[playerid] == TEAM_COPS)
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid, COLOR_RED, "You're not in the police team");
        }
    }
    return 1;
}



Re: Only police can enter vehicle - Dusan01 - 10.10.2015

code should look like this:
PHP код:
public OnPlayerStateChange(playeridnewstateoldstate) {
    if (
oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER) {
        new 
newcar GetPlayerVehicleID(playerid);
        if (
CopCar(newcar)) {
            if (
gTeam[playerid] != TEAM_COPS) {
                
RemovePlayerFromVehicle(playerid);
                
SendClientMessage(playeridCOLOR_RED"You're not in the police team");
            }
        }
    }
    return 
1;




Re: Only police can enter vehicle - Sellize - 10.10.2015

PHP код:
public OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
     {
        new 
newcar GetPlayerVehicleID(playerid);
        if(
CopCar(newcar))
        {
             if (
gTeam[playerid] != TEAM_COPS){
                
RemovePlayerFromVehicle(playerid);
                
SendClientMessage(playeridCOLOR_RED"You're not in the police team"); return 1; }
            
// continued code if the player is a cop
        
}
    }
    return 
1;




Re: Only police can enter vehicle - N0FeaR - 10.10.2015

Quote:
Originally Posted by Sellize
Посмотреть сообщение
PHP код:
public OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
     {
        new 
newcar GetPlayerVehicleID(playerid);
        if(
CopCar(newcar))
        {
             if (
gTeam[playerid] != TEAM_COPS){
                
RemovePlayerFromVehicle(playerid);
                
SendClientMessage(playeridCOLOR_RED"You're not in the police team"); return 1; }
            
// continued code if the player is a cop
        
}
    }
    return 
1;

Lol i just realize to put it on OnPlayerStateChange instead of onplayernetervehicle thx!