08.08.2006, 19:33
I add modify good for LVDM.
He check when user is registered and when is not login in 60s, kick him.
code:
create user timer when is player registered
user timer function:
Notify text timer function:
Kill timer when player disconect:
This is all, not optimized code, thx for help with optimizing...
btw: is good add timer for save world(when server crasht), after 5 min interval save all connected user money.
He check when user is registered and when is not login in 60s, kick him.
code:
Code:
//authorize timeout #define AUTH_TIMEOUT 60000 #define NOTIFY_TIME 10000 #define NOTIFY_TIMEOUT 15000 //player timer ids new PLAYERLIST_timer[MAX_PLAYERS];
Code:
public OnPlayerConnect(playerid) { PLAYERLIST_authed[playerid]=false; //have account? if(udb_Exists(PlayerName(playerid))){ new str[50]; SystemMsg(playerid,"This user have account pleas register to 60s or you be kicked!(/login pass)"); format(str,sizeof(str),"TIPL_%i",playerid); PLAYERLIST_timer[playerid] = SetTimer(str,AUTH_TIMEOUT,0); format(str,sizeof(str),"TNOT_%i",playerid); PLAYERLIST_timer[playerid] = SetTimer(str,NOTIFY_TIME,0); } else{ SystemMsg(playerid,"You can register /register pass"); } return true; }
Code:
//optimize this SetTimerEx (from tse) not work! public TIPL_0(){TimerIsPlayerLoged(1);} ..... ..... public TIPL_99(){TimerIsPlayerLoged(99);} public TimerIsPlayerLoged(playerid){ new str[256]; if(!IsPlayerConnected(playerid)) return; if(PLAYERLIST_authed[playerid]){ SystemMsg(COLOR_SYSTEM,"Byl jsi uspesne autorizovan!"); } else{ format(str,sizeof(str),"User %s has not be autorized, kicked!",PlayerName(playerid)); SendClientMessageToAll(COLOR_SYSTEM,str); Kick(playerid); } }
Code:
//optimize this SetTimerEx (from tse) not work! public TNOT_0(){TimerNotify(0);} .... .... public TNOT_99(){TimerNotify(99);} public TimerNotify(playerid){ if(!IsPlayerConnected(playerid)) return; SystemMsg(playerid,"This user have account pleas register to 60s or you be kicked!(/login pass)"); GameTextForPlayer(playerid,"~R~This user have account pls register to 60s or you be kicked!(/login pass)",NOTIFY_TIMEOUT,1); }
Code:
public OnPlayerDisconnect(playerid) { .. KillTimer(PLAYERLIST_timer[playerid]); ... }
btw: is good add timer for save world(when server crasht), after 5 min interval save all connected user money.