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. |
dcmd_login(playerid,params[])
{
if (PLAYERLIST_authed[playerid]) return SystemMsg(playerid,"[ERROR] You are already logged in.");
if (!udb_Exists(PlayerName(playerid))) return SystemMsg(playerid,"[ERROR] Account doesn't exist, please register. [USAGE] '/register password'.");
if (strlen(params)==0) return SystemMsg(playerid,"[USAGE] '/login password'");
if (udb_CheckLogin(PlayerName(playerid),params)) {
LoadFile(playerid);
SetTimerEx("SkipSpawn",1,0,"i",playerid);
return SystemMsg(playerid,"[SUCCESS] Succesfully logged in!");
}
return SystemMsg(playerid,"[ERROR] Wrong password, please try again.");
}
//Top
new PTimer[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
PTimer[playerid] = SetTimerEx("KickTimer", 60000, false, "d", playerid);
SendClientMessage(playerid, COLOR, "You have 60 seconds to login/register or you will be kicked!");
return 1;
}
forward KickTimer(playerid);
public KickTimer(playerid)
{
if(!PLAYERLIST_authed[playerid])
{
new Pname[24];
GetPlayerName(playerid, Pname, 24);
format(str, sizeof(str), "***INVALID LOGIN: User %s has not be logged in!", Pname);
SendClientMessageToAll(COLOR,str);
Kick(playerid);
}
return 1;
}