I seem to fail again O_o
#1

Hey.
Another failure occurred ><"

This time,I got failed on scripting a wanted level increase if a player which is not a cop or a medic enters a law enforcement vehicle.

Code:
pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(pInfo[playerid][Team] != TEAM_COPS || pInfo[playerid][Team] != TEAM_MEDICS)
        {
            if(GetPlayerVehicleID(playerid) == Ambulance[0] || Ambulance[1])
            {
                SendClientMessage(playerid, Orange, "Felony commited,stolen law enforcement vehicle(+2 wanted level)");
                SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid)+2);
                for(new cop; cop < MAX_PLAYERS; cop++)
                {
                    if(IsPlayerConnected(cop))
                    {
                        if(pInfo[cop][Team] == TEAM_COPS)
                        {
                            format(gstring,256,"Felony commited: the player %s has stolen a law enforcement vehicle.",pName(playerid));
                            SendClientMessage(cop,lBlue,gstring);
                        }
                    }
                }
            }
        }
    }
    return 1;
}
The problem is,it sends me both of the messages and raises my wanted level in two starts EVEN though I'm a cop.

What the hell?
Reply
#2

pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(pInfo[playerid][Team] != TEAM_COPS || pInfo[playerid][Team] != TEAM_MEDICS)
        {
            if(GetPlayerVehicleID(playerid) == Ambulance[0] || Ambulance[1])
            {
                SendClientMessage(playerid, Orange, "Felony commited,stolen law enforcement vehicle(+2 wanted level)");
                SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid)+2);
                for(new cop; cop < MAX_PLAYERS; cop++)
                {
                    if(IsPlayerConnected(cop))
                    {
                        if(pInfo[cop][Team] == TEAM_COPS)
                        {
                            format(gstring,256,"Felony commited: the player %s has stolen a law enforcement vehicle.",pName(playerid));
                            SendClientMessage(cop,lBlue,gstring);
                            return 1;
                        }
                    }
                }
            }
        }
        return 1;
    }
    return 1;
}
Reply
#3

< Deleted > Misunderstood
Reply
#4

Quote:
Originally Posted by oliverrud
Посмотреть сообщение
pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(pInfo[playerid][Team] != TEAM_COPS || pInfo[playerid][Team] != TEAM_MEDICS)
        {
            if(GetPlayerVehicleID(playerid) == Ambulance[0] || Ambulance[1])
            {
                SendClientMessage(playerid, Orange, "Felony commited,stolen law enforcement vehicle(+2 wanted level)");
                SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid)+2);
                for(new cop; cop < MAX_PLAYERS; cop++)
                {
                    if(IsPlayerConnected(cop))
                    {
                        if(pInfo[cop][Team] == TEAM_COPS)
                        {
                            format(gstring,256,"Felony commited: the player %s has stolen a law enforcement vehicle.",pName(playerid));
                            SendClientMessage(cop,lBlue,gstring);
                            return 1;
                        }
                    }
                }
            }
        }
        return 1;
    }
    return 1;
}
Sorry,but it still doesn't work :/
Reply
#5

Try:
Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{    
	if(newstate == PLAYER_STATE_DRIVER && oldstate != PLAYER_STATE_DRIVER) // not important but good to write, this is not the problem though.  
	{
		if(pInfo[playerid][Team] == TEAM_COPS || pInfo[playerid][Team] == TEAM_MEDICS) return 1;
        
		if(GetPlayerVehicleID(playerid) == Ambulance[0] || Ambulance[1])            
		{                
			SendClientMessage(playerid, Orange, "Felony commited,stolen law enforcement vehicle(+2 wanted level)");                
			SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid)+2);                
			for(new cop; cop < MAX_PLAYERS; cop++)                
			{                    
				if(IsPlayerConnected(cop))                    
				{                       
					if(pInfo[cop][Team] == TEAM_COPS)                        
					{                            
						format(gstring,256,"Felony commited: the player %s has stolen a law enforcement vehicle.",pName(playerid));                            					SendClientMessage(cop,lBlue,gstring);                       
					}                    
				}                
			}            
		}        
	}    
	return 1;
}
If that doesn't work, try:

Код:
public OnPlayerEnterVehicle(playerid,vehicleid)
{    
	
	if(pInfo[playerid][Team] == TEAM_COPS || pInfo[playerid][Team] == TEAM_MEDICS) return 1;
        
	if(vehicleid == Ambulance[0] || Ambulance[1])            
	{                
		SendClientMessage(playerid, Orange, "Felony commited,stolen law enforcement vehicle(+2 wanted level)");                
		SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid)+2);                
		for(new cop; cop < MAX_PLAYERS; cop++)                
		{                    
			if(IsPlayerConnected(cop))                    
			{                       
				if(pInfo[cop][Team] == TEAM_COPS)                        
				{                            
					format(gstring,256,"Felony commited: the player %s has stolen a law enforcement vehicle.",pName(playerid));                            							SendClientMessage(cop,lBlue,gstring);                       
				}                    
			}                
		}            
	}        
	return 1;
}
Reply
#6

Take it rather easy, you've got:

pawn Код:
if(pInfo[playerid][Team] != TEAM_COPS || pInfo[playerid][Team] != TEAM_MEDICS)
Checks if he isn't a cop OR isn't a medic, so if he'd be a medic but not a cop I'd trigger, and the other way around.


pawn Код:
if(pInfo[playerid][Team] != TEAM_COPS && pInfo[playerid][Team] != TEAM_MEDICS)
Checks if he isn't a medic AND isn't a cop.

Edit to Dhan: Second thing you posted will probably fail ^^. You're first checking if he's a medic/cop and after that checking his vehicle model D:
Reply
#7

DJDhan,you are the f****** savior dude

Thanks,the first one worked ^_^

@Hiddos- Thank you too,I know not to use || on this type of functions from now on,it was a confusion,thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)