[Tutorial] How-To: Get PlayerID - OnRconLoginAttempt
#1

This tutorial will show you guys how you can extract possible player id's from OnRconLoginAttempt. Note: If multiple players are on with the same IP it might not work correctly. Alright, so the first thing are the requirements for this tutorial:

Basic SA:MP Pawn Package(sa-mp.com/downloads)
Foreach Include(OPTIONAL)

Then just put your includes at the top...

#include a_samp
#include foreach // Optional

Okay, so let's get started. You'll need to put OnRconLoginAttempt...

Code:
public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}
Okay so assuming we're using foreach(foreach include) you'll need to define "i" which will be the connected players.

Code:
foreach(Player, i) {
Now the first thing we'll do is check if the IP matches the IP that attempted to login to RCON... But first we'll need to loop through the IP'S...
Code:
new iIP;
GetPlayerIp(i,iIP, sizeof(iIP));
if(!strcmp(ip, pip, true)) // Now we'll use strcmp to check if they match.
{ // Don't forget your bracket. //
new playerid = i;
if(playerid == INVALID_PLAYER_ID) return 0;
// Your code bla bla bla
}
}
NOTE: If you don't want to use foreach replace foreach with:
Code:
for(new i=0; i<MAX_PLAYERS; i++)
 {
So now you can have a playerid to work with... If you have any questions regarding this tutorial feel free to ask.
- Abagail
Reply
#2

You can get the exact player who logged in and there's an include for that: https://sampforum.blast.hk/showthread.php?tid=491835
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)