Today gonna learn ya how to make OnPlayerLoginAsRcon(playerid) callback ;_; so let's begin,
how will we do it? Well, we gonna make a simple var and reset it / make the value of it 0 on player connect, then on his login as rcon we will search for player that is rcon and his value is 0 we will make it 1 and get his id.
Words easer than scripts ;_;.
first we will add samp team and foreach loops includes,
Foreach download link:
http://forum.sa-mp.com/showthread.php?t=570868
second we will make / add our var
now we will reset our var on player connect [ if he is rcon we won't touch it cause players keep rcon, if /gmx used c: ]
now we will do some job onrconloginattempt to check if new player loggedin as rcon
now we will make our timer codes
now we can do multi things with our OnPlayerRconLogin callback,
example here I got player name and shared it for players...
I hope it will be useful for ya ;_;
Here's CallRemoteFunctions wiki page...
https://wiki.sa-mp.com/wiki/CallRemoteFunction
Full code:
how will we do it? Well, we gonna make a simple var and reset it / make the value of it 0 on player connect, then on his login as rcon we will search for player that is rcon and his value is 0 we will make it 1 and get his id.
Words easer than scripts ;_;.
first we will add samp team and foreach loops includes,
Foreach download link:
http://forum.sa-mp.com/showthread.php?t=570868
PHP Code:
#include a_samp
#include foreach
PHP Code:
new P_Rconz[MAX_PLAYERS]; // we add [MAX_PLAYERS] to make it var per player...
PHP Code:
public OnPlayerConnect(playerid) { // on player connect callback
if(!IsPlayerAdmin(playerid)) P_Rconz[playerid] = 0; // var reset with if player not rcon check to avoid bugs when /rcon gmx used...
return 1;
}
PHP Code:
public OnRconLoginAttempt(ip[], password[], success) // on rconloginattempt
{
if(success) SetTimer("FollowDaRconz", 250, 0);// check if successed to login in and make a timer to search for the player : NOTE I used timer cause it not make player rcon directly after he login on this callback...
}
PHP Code:
forward public FollowDaRconz(); // forwarding our timer
public FollowDaRconz() { // when our timer being called
foreach(new i : Player) { // loob between available players ids
if(IsPlayerAdmin(i) && !P_Rconz[i]) { // if player is rcon and his rcon var is 0
CallRemoteFunction("OnPlayerLoginAsRcon", "i", i); // call our remote functions of OnPlayerLoginAsRcon
P_Rconz[i] = 1; // increase Rcon var of the player
}
}
}
example here I got player name and shared it for players...
PHP Code:
forward public OnPlayerLoginAsRcon(rconid); // forwarding our OnPlayerRconLogin callback
public OnPlayerLoginAsRcon(rconid) {// when it got called
new name[MAX_PLAYERS],str[80]; // add new vars to save player name and put it on a message
GetPlayerName(rconid, name, sizeof name); // get player name on our var
format(str, sizeof str,"%s Logged In As Rcon",name); // format our message to put player name and some texts in it
SendClientMessageToAll(-1, str); // send the message to all players
}
Here's CallRemoteFunctions wiki page...
https://wiki.sa-mp.com/wiki/CallRemoteFunction
Full code:
PHP Code:
#include a_samp
#include foreach
new P_Rconz[MAX_PLAYERS];
public OnPlayerConnect(playerid) {
if(!IsPlayerAdmin(playerid)) P_Rconz[playerid] = 0;
return 1;
}
public OnRconLoginAttempt(ip[], password[], success) // on rconloginattempt
{
if(success) SetTimer("FollowDaRconz", 250, 0);// check if successed to login in and make a timer to search for the player : NOTE I used timer cause it not make player rcon directly after he login on this callback...
}
forward public FollowDaRconz(); // forwarding our timer
public FollowDaRconz() { // when our timer being called
foreach(new i : Player) { // loob between available players ids
if(IsPlayerAdmin(i) && !P_Rconz[i]) { // if player is rcon and his rcon var is 0
CallRemoteFunction("OnPlayerLoginAsRcon", "i", i); // call our remote functions of OnPlayerLoginAsRcon
P_Rconz[i] = 1; // increase Rcon var of the player
}
}
}
forward public OnPlayerLoginAsRcon(rconid); // forwarding our OnPlayerRconLogin callback
public OnPlayerLoginAsRcon(rconid) {// when it got called
new name[MAX_PLAYERS],str[80]; // add new vars to save player name and put it on a message
GetPlayerName(rconid, name, sizeof name); // get player name on our var
format(str, sizeof str,"%s Logged In As Rcon",name); // format our message to put player name and some texts in it
SendClientMessageToAll(-1, str); // send the message to all players
}