Help with Vehicle
#1

hello

On my server, when you enter a Police Vehicle and you are not a Police Officer, you get 4 Wanted Level Stars.

For some reason, when a player steals a cop car and then dies inside the cop car, they get another 4 Wanted Levels and a message Saying Police Vehicle Theft again.
I've tried for the past 4 hours to fix this but I haven't been able too.

It should only come up when they steal the car and not when they die. How can i fix this?

Here is a snippet of my code, it us under OnPlayerStateChange

PHP код:
    if(GetVehicleModel(vehicleid) == 596)
    {
        if(
pInfo[playerid][pCop] == 1)
        {
        
GameTextForPlayer(playerid,"Police Car LS",3000,1);
        }
        if(
pInfo[playerid][pCop] == 0)
        {
        
GameTextForPlayer(playerid,"Police Car LS",3000,1);
        
SendClientMessage(playeridCOLOR_YELLOW"** Crime Alert: {FFFFFF}Police Vehicle Theft {FFFF00}- Wanted Level {ffffff}+4.");
        
UpdateWantedLevel(playeridGetPlayerWantedLevel(playerid) + 4);
        
pInfo[playerid][pStarsAtt]+= 4;
        }
    } 
Reply
#2

Try putting it under OnPlayerVehicleEnter, something like that. i think its to do with the state change.
Reply
#3

could you give me an example because i tried this, and it isn't working, it compiles but doesn't work

PHP код:
public OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
    new 
string[128];
    
format(stringsizeof(string), "%s"VehicleNames[GetVehicleModel(GetPlayerVehicleID(ID))-400]);
    
GameTextForPlayer(playeridstring30001);
    
    if(
GetVehicleModel(vehicleid) == 596){
    if(
pInfo[playerid][pCop] == 1)
    {
        
GameTextForPlayer(playerid,"Police Car LS",3000,1);
    }
        if(
pInfo[playerid][pCop] == 0)
    {
    
GameTextForPlayer(playerid,"Police Car LS",3000,1);
    
SendClientMessage(playeridCOLOR_YELLOW"** Crime Alert: {FFFFFF}Police Vehicle Theft {FFFF00}- Wanted Level {ffffff}+4.");
    
UpdateWantedLevel(playeridGetPlayerWantedLevel(playerid) + 4);
    
pInfo[playerid][pStarsAtt]+= 4;
    }
    }
    return 
1;

Reply
#4

Try this:

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(GetVehicleModel(vehicleid) == 596)
        {
            if(pInfo[playerid][pCop] == 1)
            {
                GameTextForPlayer(playerid,"Police Car LS",3000,1);
            }
            if(pInfo[playerid][pCop] == 0)
            {
                GameTextForPlayer(playerid,"Police Car LS",3000,1);
                SendClientMessage(playerid, COLOR_YELLOW, "** Crime Alert: {FFFFFF}Police Vehicle Theft {FFFF00}- Wanted Level {ffffff}+4.");
                UpdateWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 4);
                pInfo[playerid][pStarsAtt]+= 4;
            }
        }
    }
    return 1;
}
Reply
#5

^ i already have that, it still sets the players wanted level 2 times, once when he enters the vehicle then it sets it again when he dies inside the vehicle.
Reply
#6

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(GetVehicleModel(vehicleid) == 596)
        {
            if(pInfo[playerid][pCop] == 1)
            {
                GameTextForPlayer(playerid,"Police Car LS",3000,1);
            }
            if(pInfo[playerid][pCop] == 0)
            {
                GameTextForPlayer(playerid,"Police Car LS",3000,1);
                SendClientMessage(playerid, COLOR_YELLOW, "** Crime Alert: {FFFFFF}Police Vehicle Theft {FFFF00}- Wanted Level {ffffff}+4.");
                SetPlayerWantedLevel(playerid,4);
                pInfo[playerid][pStarsAtt] = 4;
            }
        }
    }
    return 1;
}
Maybe this?
Reply
#7

all good guys, i got it, thanks for the help

PHP код:
    if(GetVehicleModel(vehicleid) == 427)
    {
        if(
oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER && pInfo[playerid][pCop] == 1)
        {
        
GameTextForPlayer(playerid,"Enforcer",3000,1);
        }
        if(
oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_PASSENGER && pInfo[playerid][pCop] == 1)
        {
        
GameTextForPlayer(playerid,"Enforcer",3000,1);
        }
        if(
oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_PASSENGER && pInfo[playerid][pCop] == 0)
          {
          
GameTextForPlayer(playerid,"Enforcer",3000,1);
          }
        else if(
oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER && pInfo[playerid][pCop] == 0)
        {
        
GameTextForPlayer(playerid,"Enforcer",3000,1);
        
SendClientMessage(playeridCOLOR_YELLOW"** Crime Alert: {FFFFFF}Police Vehicle Theft {FFFF00}- Wanted Level {ffffff}+4.");
        
UpdateWantedLevel(playeridGetPlayerWantedLevel(playerid) + 4);
        
pInfo[playerid][pStarsAtt]+= 4;
        }
    } 
works perfect
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)