Loop problem - 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: Loop problem (
/showthread.php?tid=123380)
Loop problem -
nesty - 25.01.2010
hi, guys can someone tell me why my ping code doesn't work?
I tried a lot of times to fix that but nothing happens. (lol I never liked loops)
i hope u can tell me what i did wrong so i can learn about that.
pawn Код:
public player_ping(playerid)
{
new string[256];
new ping[playerid];
for(new i=0; i<MAX_PLAYERS; i++)
ping=GetPlayerPing(playerid);
format(string,sizeof(string),"ping: %d",ping[playerid]);
SendClientMessage(i,COLOR_LILA,string);
}
sry i forgot to tell u what actually should do the code.
It has to send a message to the player who wanna see his ping.
Re: Loop problem -
akis_tze - 25.01.2010
Код:
public player_ping(playerid)
{
new string[256];
new ping[playerid];
for(new i=0; i<MAX_PLAYERS; i++)
{
ping=GetPlayerPing(i);
format(string,sizeof(string),"ping: %d",ping[i]);
SendClientMessage(i,COLOR_LILA,string);
}
}
i think now works
Re: Loop problem -
nesty - 25.01.2010
htanks for the anwser but it still doesen't work. (lol i thought it isn't relevant to set brackets to a for loop)
Can u or someone fix that or explain me my mistake pls.
Re: Loop problem -
¤Adas¤ - 25.01.2010
Код:
public player_ping()
{
new string[256];
new ping;
for(new i; i<MAX_PLAYERS; i++)
{
ping=GetPlayerPing(i);
format(string,sizeof(string),"ping: %d",ping);
SendClientMessage(i,COLOR_LILA,string);
}
}
Try this..
Re: Loop problem -
nesty - 25.01.2010
thanks but i get errors if i compile your code
Re: Loop problem -
¤Adas¤ - 25.01.2010
What errors? and.. send me bigger part of your code please..
Re: Loop problem -
Niixie - 25.01.2010
When you do that loop it makes playerid to i.
With loop this will be correct:
SetPlayerScore(i, 1234);
without loop this will be correct:
SetPlayerScore(playerid, 1234);
Re: Loop problem -
nesty - 25.01.2010
ok here the rest of the code:
pawn Код:
forward player_ping(playerid);
pawn Код:
SetTimer("player_ping", 250, true); //ONGamemodeInit
pawn Код:
public player_ping(playerid)
{
new string[256];
new ping[playerid];
for(new i=0; i<MAX_PLAYERS; i++)
{
ping=GetPlayerPing(i);
format(string,sizeof(string),"ping: %d",ping);
SendClientMessage(i,COLOR_LILA,string);
}
}
hope this wil help u
Re: Loop problem -
¤Adas¤ - 25.01.2010
Quote:
Originally Posted by nesty
ok here the rest of the code:
pawn Код:
forward player_ping(playerid);
pawn Код:
SetTimer("player_ping", 250, true); //ONGamemodeInit
pawn Код:
public player_ping(playerid) { new string[256]; new ping[playerid]; for(new i=0; i<MAX_PLAYERS; i++) { ping=GetPlayerPing(i); format(string,sizeof(string),"ping: %d",ping); SendClientMessage(i,COLOR_LILA,string); } }
hope this wil help u
|
This will not help...
Why to do: forward player_ping(playerid); when it is under game mode init? USE: forward player_ping();
and
pawn Код:
public player_ping()
{
new string[50];
new ping;
for(new i; i<GetMaxPlayers(); i++)
{
ping = GetPlayerPing(i);
format(string,sizeof(string),"ping: %d",ping);
SendClientMessage(i,COLOR_LILA,string);
}
}
Re: Loop problem -
nesty - 25.01.2010
hey thanks its work perfectly really thanks