Posts: 108
Threads: 21
Joined: Aug 2016
Hey guys i'm doing a vehicle entry thing where if a TEAM_DRIVER enters a TEAM_COP car he'll get wanted stars.
everything works good expect that if he exits the car and reenter he'll get another set of stars. i want it if he exits the car and enters another vehicle then
ReEnter the previous vehicle he'll then get another set of stars
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(vehicleid == Car[TEAM_COP])
{
if (VehicleEntry[playerid] == 0)
{
if(gTeam[playerid] == TEAM_CIV)
{
SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid) + 10);
VehicleEntry[playerid] = 1;
}
}
}
}
return 1;
}
What should i do?
Posts: 11,827
Threads: 33
Joined: Dec 2011
Reputation:
0
A player-array that stores the last vehicle ID the player entered. In OnPlayerStateChange, get the current vehicle ID and compare it to the saved one. If they do not match, increase wanted level. Last, set to the variable the current vehicle ID.
Posts: 108
Threads: 21
Joined: Aug 2016
Quote:
Originally Posted by Konstantinos
A player-array that stores the last vehicle ID the player entered. In OnPlayerStateChange, get the current vehicle ID and compare it to the saved one. If they do not match, increase wanted level. Last, set to the variable the current vehicle ID.
|
Should i use PVars?
Edit: Also,wouldn't that be a problem? if i exit a police cheetah then enter, enter cheetah wouldn't i get the stars?
Hope you understand what i just said.
Posts: 11,827
Threads: 33
Joined: Dec 2011
Reputation:
0
Pvars are slower than arrays.
If you exit a police cheetah and then enter a normal cheetah (different vehicle ID, not vehicle model ID), yes you'll get the starts.
Posts: 108
Threads: 21
Joined: Aug 2016
Quote:
Originally Posted by Konstantinos
Pvars are slower than arrays.
If you exit a police cheetah and then enter a normal cheetah (different vehicle ID, not vehicle model ID), yes you'll get the starts.
|
What do you suggest.
couldnt i check of its a cop car he exit then increase the size?
Posts: 108
Threads: 21
Joined: Aug 2016
Posts: 108
Threads: 21
Joined: Aug 2016
Posts: 108
Threads: 21
Joined: Aug 2016
Quote:
Originally Posted by Mencent
Hello.
Write it like this. When you have questions or some other Problems where you Need help then feel free to ask.
PHP код:
new lastVehicle[MAX_PLAYERS];//under includes
//your callback:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(vehicleid == Car[TEAM_COP] && gTeam[playerid] == TEAM_CIV && VehicleEntry[playerid] == 0)
{
if(lastVehicle[playerid] != vehicleid)
{
SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid) + 10);
VehicleEntry[playerid] = 1;
lastVehicle[playerid] = vehicleid;
}
}
}
return 1;
}
|
Doesn't work,let me explain a bit more, i've 3 vehicles (Cop Cheetah,Cop Cheetah,Cop Infernus) all 3 are cop cars if a team civ enter Vehicle 1 (1 of the cop cheetahs) he'll get 10 wanted stars if he exits then reenter that same car he wont get anystars has he was already there,but if he goes into the 2nd cop cheetah or infernus his wanted start would be 20 now.
Edit:
i've my cars defined as
Код:
Car[TEAM_COPS] = AddStaticVehicle(...);
should i change it to.
Код:
Car[TEAM_COPS][0] = AddStaticVehicle(...);
Overall. could that be the problem or provided code?
Posts: 1
Threads: 0
Joined: Oct 2016
Reputation:
0
Yes,the code mencent provided is correct.