18.04.2007, 01:12
A way to get a player's disconnect reason. May not be advanced, but it's useful.
A simple way to test it.
OnPlayerScoreChange and OnPlayerGetMoney
Found in my xLog script, but just thought I should post it here.
pawn Код:
new kicked[MAX_PLAYERS];
pawn Код:
#define ban 2
#define kick 1
stock Kick2(playerid)
{
kicked[playerid] = 1;
return Kick(playerid);
}
pawn Код:
stock Ban2(playerid)
{
kicked[playerid] = 2;
return Ban(playerid);
}
pawn Код:
public OnPlayerDisconnect(playerid)
{
if(kicked[playerid] == ban)
{
//your code
}
if(kicked[playerid] == kick)
{
//your code
}
return 1;
}
Found in my xLog script, but just thought I should post it here.
pawn Код:
SetTimer("CheckMoney",1000,1);
SetTimer("CheckScore",1000,1);
pawn Код:
public CheckMoney()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(M[i] < GetPlayerMoney(i))
{
OnPlayerGetMoney(i,GetPlayerMoney(i),M[i]);
}
M[i] = GetPlayerMoney(i);
}
}
pawn Код:
public CheckScore()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(S[i] < GetPlayerScore(i))
{
OnPlayerScoreChange(i,GetPlayerScore(i),S[i]);
}
S[i] = GetPlayerScore(i);
}
}
pawn Код:
public OnPlayerGetMoney(playerid,newmoney,oldmoney)
{
//Do whatever you want when a player gets or loses money
return 1;
}
public OnPlayerScoreChange(playerid,newscore,oldscore)
{
//Do whatever you want when a player changes score
return 1;
}