Undefined Symbol " playerid " - 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)
+--- Thread: Undefined Symbol " playerid " (
/showthread.php?tid=612098)
Undefined Symbol " playerid " -
Farzam - 14.07.2016
And yes. I got this error and I have to fix it. Because I'm using it for an important thing.
Do anyone have any idea? For to how to define playerid.
PHP код:
public OnRconLoginAttempt(ip[], password[], success)
{
if(success == 1) {
new Name[32], string[128];
GetPlayerName(playerid, Name, sizeof Name);
format(string, sizeof string, " %s | %s | %s",Name(playerid), ip, success);
fwrite("rcons.txt", string)
}
else
{
if(success == 0)
{
Ban(playerid);
}
}
return 1;
}
Re: Undefined Symbol " playerid " -
Stinged - 14.07.2016
https://sampwiki.blast.hk/wiki/OnRconLoginAttempt
Check the example they show.
playerid isn't available in OnRconLoginAttempt, which is why you'll have to use a loop to check which player IP matches the IP that attempted to login.
Re: Undefined Symbol " playerid " -
Freaksken - 14.07.2016
Since OnRconLoginAttempt doesn't have a playerid parameter, you will have to loop through all online players and compare their ip to the given ip.
Код:
public OnRconLoginAttempt(ip[], password[], success)
{
new playerip[15 + 1];
for(new playerid = 0, highestPlayerid = GetPlayerPoolSize(); playerid <= highestPlayerid; playerid++) {
if(IsPlayerConnected(otherplayerid) && !IsPlayerNPC(playerid)) {
GetPlayerIp(playerid, playerip, sizeof(playerip));
if(!strcmp(ip, playerip, true)) { //If a player's IP is the IP that did the login
if(success) {
//Successful login
} else {
//Unsuccessful login
}
break;
}
}
}
return 1;
}
EDIT:
Stinged was faster.
Re: Undefined Symbol " playerid " -
Farzam - 14.07.2016
So there is no way to get the player name who tried to login to RCON?
Re: Undefined Symbol " playerid " -
Freaksken - 14.07.2016
Yes there is, with the code above or in
https://sampwiki.blast.hk/wiki/OnRconLoginAttempt.
See this part of my code:
Код:
if(!strcmp(ip, playerip, true)) {
}
Within those brackets, thats the player that did the login. Just use 'playerid' in there.
Re: Undefined Symbol " playerid " -
Farzam - 14.07.2016
Alright, Thank you for the code and explaination. I have given rep to both of you.