Only police can enter vehicle
#1

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;
}
Reply
#2

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;

Reply
#3

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;

Reply
#4

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!
Reply


Forum Jump:


Users browsing this thread: