What is wrong with wanted .. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: What is wrong with wanted .. (
/showthread.php?tid=267029)
What is wrong with wanted .. -
qUick1337 - 06.07.2011
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
Re: What is wrong with wanted .. -
Shadoww5 - 07.07.2011
Where do you this callback ?
Re: What is wrong with wanted .. -
Babul - 07.07.2011
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
Re: What is wrong with wanted .. -
qUick1337 - 07.07.2011
/info purpose

don't working
Re: What is wrong with wanted .. -
qUick1337 - 07.07.2011
bump..