[SOLVED] fixing script
#1

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];
create user timer when is player registered
Код:
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);
	}
}
Notify text timer function:
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);
}
Kill timer when player disconect:
Код:
public OnPlayerDisconnect(playerid) {
 ..
 KillTimer(PLAYERLIST_timer[playerid]);
...
}
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.
can someone complete this script? As I'd like to have this, it's a timer which kicks a player when he/she is not logged in after a minute. And it is with a textdraw which I don't fully know how to add that. I'd be happy if someone could complete it. (a/o explain me on how to) (It sounds lazy of me, but I really don't know how to make this)

Thanks in advance
Reply
#2

What login variable are you using? Then I can just quickly write it up, it will take me 2 seconds .
Reply
#3

Currently:

pawn Код:
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.");
}
if you meant that,
thanks in advance!

KnooL
Reply
#4

bump
Reply
#5

pawn Код:
//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;
}

Reply
#6

No errors, gonna check soon, thank you! Maybe I'm asking too much of you, I'am sorry of that. But could you make a textdraw with the remaining time?
Reply
#7

!bump
Reply
#8

To create a textdraw just search for one of the Text Draw Creators on the forum..
Reply
#9

ugh.. If you read my first post better, I don't want to create a 'normal' textdraw. I'm searching for someone who can explain me how to put / make the counting in a textdraw.
Reply
#10

http://forum.sa-mp.com/index.php?topic=116775.0
Sorry, something like this ^^?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)