What is wrong with wanted ..
#1

What is wrong with this command:
Код:
public playerwanted(playerid)
{

	if(IsPlayerConnected(playerid))
	{
	new count;
    for(new i = 0; i < MAX_PLAYERS; i++)
	{
    if(gTeam[i] == 3 && CrimInRange(50.0, playerid,i))
    {
    count = 1;
    }
    }
    if(count == 1)
	{
    WantedLevel[playerid] += 0;
    WantedPoints[playerid] += 0;
    return 1;
	}
    if(WantedLevel[playerid] > 0)
    {
    WantedLevel[playerid] -= 1;
    WantedPoints[playerid] -= 2;
    new string[255];
    new wlevel = WantedLevel[playerid];
    format(string, sizeof(string), "Current Wanted Level: %d", wlevel);
    SendClientMessage(playerid, COLOR_YELLOW, string);
    return 1;
	}
    return 1;
    }

	return 0;
}
My wanted is decreasing and i don't get "Current Wanted Level" in chat
Reply
#2

Where do you this callback ?
Reply
#3

hm...
Код:
if(gTeam[i] == 3 && CrimInRange(50.0, playerid,i))
{
	count = 1;
}
this loop through all players looks ok, but it can be stopped as soon it found a player in range, to save some redundant time, since count=1; only needs to get set once.


Код:
WantedLevel[playerid] += 0;
WantedPoints[playerid] += 0;
return 1;
? adding 0 to a wantedlevel will result in the same wantedlevel. also the return 1; will break the entire function,try:
Код:
WantedLevel[playerid] += 1;
WantedPoints[playerid] += 2;
//without the return 1; so the callback can go on...
Код:
if(WantedLevel[playerid] > 0)
{
	WantedLevel[playerid] -= 1;
	WantedPoints[playerid] -= 2;
	new string[255];
	new wlevel = WantedLevel[playerid];
	format(string, sizeof(string), "Current Wanted Level: %d", wlevel);
	SendClientMessage(playerid, COLOR_YELLOW, string);
	return 1;
}
you dont get your wantedlevel printed coz it only prints out if the playerid's wanted > 0, an innocent player should get at least a "you are not wanted".

long words, short sense. i fixed the code a bit more, give it a try. sry if i fucked it up entirely
Код:
public playerwanted(playerid)
{
	if(IsPlayerConnected(playerid))
	{
		new count;
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
			if(gTeam[i] == 3 && CrimInRange(50.0, playerid,i))
			{
				count = 1;
				continue;
			}
		}
		if(count == 1)
		{
			WantedLevel[playerid] += 1;
			WantedPoints[playerid] += 2;
		}
		new string[128];
		if(WantedLevel[playerid] > 0)
		{
			WantedLevel[playerid] -= 1;
			WantedPoints[playerid] -= 2;
			format(string, sizeof(string), "Current Wanted Level: %d", WantedLevel[playerid]);
		}
		else
		{
			format(string, sizeof(string), "You are innocent atm.");
		}
		SendClientMessage(playerid, COLOR_YELLOW, string);
	}
	return 1;
}
edit: may i ask what the function should do? i mean, is it meant to work like a cops /report or a general /info purpose? the WantedLevel[playerid]+=0; looks odd
Reply
#4

/info purpose don't working
Reply
#5

bump..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)