25.12.2009, 23:15
Quote:
Originally Posted by fromdudbthread
add modify good for LVDM.
He check when user is registered and when is not login in 60s, kick him. Код:
//authorize timeout #define AUTH_TIMEOUT 60000 #define NOTIFY_TIME 10000 #define NOTIFY_TIMEOUT 15000 //player timer ids new PLAYERLIST_timer[MAX_PLAYERS]; Код:
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; } user timer function: 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); } Код:
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. |
Thanks in advance