Help with Vehicle -
tommzy09 - 13.12.2014
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(playerid, COLOR_YELLOW, "** Crime Alert: {FFFFFF}Police Vehicle Theft {FFFF00}- Wanted Level {ffffff}+4.");
UpdateWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 4);
pInfo[playerid][pStarsAtt]+= 4;
}
}
Re: Help with Vehicle -
MrViolence101 - 13.12.2014
Try putting it under OnPlayerVehicleEnter, something like that. i think its to do with the state change.
Re: Help with Vehicle -
tommzy09 - 13.12.2014
could you give me an example because i tried this, and it isn't working, it compiles but doesn't work
PHP код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new string[128];
format(string, sizeof(string), "%s", VehicleNames[GetVehicleModel(GetPlayerVehicleID(ID))-400]);
GameTextForPlayer(playerid, string, 3000, 1);
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;
}
Re: Help with Vehicle -
Sledgehammer - 13.12.2014
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;
}
Re: Help with Vehicle -
tommzy09 - 13.12.2014
^ 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.
Re: Help with Vehicle -
Dziugsas - 13.12.2014
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?
Re: Help with Vehicle -
tommzy09 - 13.12.2014
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(playerid, COLOR_YELLOW, "** Crime Alert: {FFFFFF}Police Vehicle Theft {FFFF00}- Wanted Level {ffffff}+4.");
UpdateWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 4);
pInfo[playerid][pStarsAtt]+= 4;
}
}
works perfect