07.07.2011, 00:37
hm...
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.
? adding 0 to a wantedlevel will result in the same wantedlevel. also the return 1; will break the entire function,try:
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
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
Код:
if(gTeam[i] == 3 && CrimInRange(50.0, playerid,i)) { count = 1; }
Код:
WantedLevel[playerid] += 0; WantedPoints[playerid] += 0; return 1;
Код:
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; }
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; }
