Little Entry Problem.
#1

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?
Reply
#2

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.
Reply
#3

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.
Reply
#4

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.
Reply
#5

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?
Reply
#6

BUMP!
Reply
#7

BUMP! (1)
Reply
#8

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(playeridnewstateoldstate)
{
    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;

Reply
#9

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(playeridnewstateoldstate)
{
    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?
Reply
#10

Yes,the code mencent provided is correct.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)