SA-MP Forums Archive
Another Help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Another Help (/showthread.php?tid=384554)



Another Help - MrReBzz - 12.10.2012

Recently I have fixed a Problem With My setlevel cmd. But Now When i Log Out, Nothing Saves

Heres My Setlevel command

Код:
dcmd_setlevel(playerid,params[])
{
	new level,id,file[256],n[MAX_PLAYER_NAME];
	new tmp[256], tmp2[256], Index,str[50];
	tmp = strtok(params,Index), tmp2 = strtok(params,Index),id = strval(tmp),level = strval(tmp2);
	GetPlayerName(id,n,MAX_PLAYER_NAME);
	format(file,sizeof(file),"SERVER_USER_FILE",n);
	if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not an RCON admin!");
	if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /setlevel <ID> <Level>");
	if(!strlen(tmp2)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /setlevel <ID> <Level>");
	if(!IsPlayerConnected(id))return SendClientMessage(playerid,COLOR_RED,"You have entered an incorrect ID"); 
	PlayerInfo[playerid][pAdminLevel] = pAdminLevel;
	dini_IntSet(file,"Level",level);
	format(str,sizeof(str),"You have set %s's level to %d",n,level);
	SendClientMessage(playerid,COLOR_BLUE,str);
	return 1;
}
Onplayer Connect
Код:
	public OnPlayerConnect(playerid)
{
	
	gPlayerLogged[playerid] = 0;
	new name[MAX_PLAYER_NAME], file[256];
	GetPlayerName(playerid, name, sizeof(name));
	format(file, sizeof(file), SERVER_USER_FILE, name);
	if (!dini_Exists(file))
	{
    	ShowPlayerDialog(playerid, 24, DIALOG_STYLE_PASSWORD, "Please Register", "Welcome, Your Account Is Not Registered. \nInput Your Password To Register Below", "Register", "Leave");
	}
	if(fexist(file))
    {
		ShowPlayerDialog(playerid, 25, DIALOG_STYLE_PASSWORD, "Please Login", "Welcome, Your Account Is Registered. \nPlease Enter Your Password To Login", "Login", "Leave");
	}
	return 1;
}
Onplayerdisconnect

Код:
public OnPlayerDisconnect(playerid, reason)
{
	new name[MAX_PLAYER_NAME], file[256];
	GetPlayerName(playerid, name, sizeof(name));
	format(file, sizeof(file), SERVER_USER_FILE, name);
    if(gPlayerLogged[playerid] == 1)
    {
  		dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]);
  		dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]);
  		dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel]);
    }
    gPlayerLogged[playerid] = 0;
	return 1;
If someone Fixes This. I can continue With My Gamemode and add admin cmds. Thanks


Re: Another Help - Kwarde - 13.10.2012

pawn Код:
if(gPlayerLogged[playerid] == 1)
    {
        dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]);
        dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]);
        dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel]);
    }
So if 'gPlayerLogged[playerid] == 1' it will save. In the codes you provided I didn't see that it was turned to '1'. You should add a debug to OnPlayerDisconnect. Like this:
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    printf("[DEBUG] gPlayerLogged (ID %d) = %d", playerid, gPlayerLogged[playerid]);
    //The rest of your code of OnPlayerDisconnect
When you disconnect, look into your server console. If you see the next text in the console when you disconnected (considdering your ID was 0): [DEBUG] gPlayerLogged (ID 0) = 0, you weren't logged in. You should then check your login part. If you see: [DEBUG] gPlayerLogged (ID 0) = 1, there is something kinda wrong .


Re: Another Help - MrReBzz - 13.10.2012

Thanks! But I Switched It To Y_INI