My server giving a random level to anyone
#1

Good evening,
my max admin lvl is 13 and when i register and login then make reconnect servr gives me a random level 100+
Код:
CMD:setlevel(playerid,params[]) {
	if(PlayerInfo[playerid][LoggedIn] == 1) {
		if(PlayerInfo[playerid][Level] >= 13 || IsPlayerAdmin(playerid)) {
		    new tmp[128], tmp2[128], Index;		tmp = strtok(params,Index), tmp2 = strtok(params,Index);
		    if(isnull(params)) return SendClientMessage(playerid, red, "{00FF40}Usage: /setlevel {FF00D9}[PlayerID] [Level] {00FF40}(0-12)");
	    	new player1, level, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
			player1 = strval(tmp);
			if(isnull(tmp2)) return SendClientMessage(playerid, red, "{00FF40}USAGE: /setlevel [playerid] [level]");
			level = strval(tmp2);

			if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
				if(PlayerInfo[player1][LoggedIn] == 1) {
					if(level > ServerInfo[MaxAdminLevel] ) return SendClientMessage(playerid,red,"ERROR: Incorrect Level");
					if(level == PlayerInfo[player1][Level]) return SendClientMessage(playerid,red,"ERROR: Player is already this level");
	       			CMDMessageToAdmins(playerid,"SETLEVEL");
					GetPlayerName(player1, playername, sizeof(playername));	GetPlayerName(playerid, adminname, sizeof(adminname));
			       	new year,month,day;   getdate(year, month, day); new hour,minute,second; gettime(hour,minute,second);

					if(level > 0) format(string,sizeof(string),"{4EEE94}Administrator %s has set you to Administrator Status {0011FF}[level %d] -|",adminname, level);
					else format(string,sizeof(string),"{4EEE94}Administrator %s has set you to Player Status {49F505}[level %d]",adminname, level);
					SendClientMessage(player1,blue,string);

					if(level > PlayerInfo[player1][Level]) GameTextForPlayer(player1,"~y~Promoted", 5000, 5);
					else GameTextForPlayer(player1,"~r~DEMOTED", 5000, 5);

					format(string,sizeof(string),"{4EEE94}You have made %s Level %d on {66CDAA}%d/%d/%d at %d:%d:%d", playername, level, day, month, year, hour, minute, second); SendClientMessage(playerid,blue,string);
					format(string,sizeof(string),"{4EEE94}Administrator %s has made %s Level %d on {0011FF}%d/%d/%d at %d:%d:%d",adminname, playername, level, day, month, year, hour, minute, second);
					SaveToFile("AdminLog",string);
					dUserSetINT(PlayerName2(player1)).("level",(level));
					PlayerInfo[player1][Level] = level;
					return PlayerPlaySound(player1,1057,0.0,0.0,0.0);
				} else return SendClientMessage(playerid,red,"ERROR: Player must be registered and logged in to be admin");
			} else return SendClientMessage(playerid, red, "{00FF40}ERROR: {03F2FF}Player is not connected");
		} else return SendClientMessage(playerid,red,"ERROR: {FF00D9}You are not a high enough {FFFFFF}level {00FF40}to use this command");
	} else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}
Код:
CMD:settemplevel(playerid,params[]) {
	if(PlayerInfo[playerid][LoggedIn] == 1) {
		if(PlayerInfo[playerid][Level] >= 12 || IsPlayerAdmin(playerid)) {
		    new tmp[128], tmp2[128], Index;		tmp = strtok(params,Index), tmp2 = strtok(params,Index);
		    if(isnull(tmp) || isnull(tmp2)) return SendClientMessage(playerid, red, "USAGE: /settemplevel [playerid] [level]");
	    	new player1, level, string[128];
			player1 = strval(tmp);
			level = strval(tmp2);

			if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
				if(PlayerInfo[player1][LoggedIn] == 1) {
					if(level > ServerInfo[MaxAdminLevel] ) return SendClientMessage(playerid,red,"ERROR: Incorrect Level");
					if(level == PlayerInfo[player1][Level]) return SendClientMessage(playerid,red,"ERROR: Player is already this level");
	       			CMDMessageToAdmins(playerid,"SETTEMPLEVEL");
			       	new year,month,day; getdate(year, month, day); new hour,minute,second; gettime(hour,minute,second);

					if(level > 0) format(string,sizeof(string),"{66CDAA}Administrator %s has temporarily set you to Administrator Status {66CDAA}[level %d]", pName(playerid), level);
					else format(string,sizeof(string),"{49F505}Administrator %s has temporarily set you to Player Status [{49F505}level %d]", pName(playerid), level);
					SendClientMessage(player1,blue,string);

					if(level > PlayerInfo[player1][Level]) GameTextForPlayer(player1,"~g~PRO~b~MO~p~TE~y~D", 5000, 5);
					else GameTextForPlayer(player1,"D~p~E~y~M~b~O~p~T~g~ED", 5000, 5);

					format(string,sizeof(string),"{49F505}You have made {00FFFF}%s {FF00FF}Level %d on {FFFF00}%d/%d/%d at %d:%d:%d", pName(player1), level, day, month, year, hour, minute, second); SendClientMessage(playerid,blue,string);
					format(string,sizeof(string),"{FF00FF}Administrator {00FFFF}%s has made %s temp Level {49F505}%d on {FF00FF}%d/%d/%d at %d:%d:%d",pName(playerid), pName(player1), level, day, month, year, hour, minute, second);
					SaveToFile("TempAdminLog",string);
					PlayerInfo[player1][Level] = level;
					return PlayerPlaySound(player1,1057,0.0,0.0,0.0);
				} else return SendClientMessage(playerid,red,"ERROR: Player must be registered and logged in to be admin");
			} else return SendClientMessage(playerid, red, "{00FF40}ERROR: {03F2FF}Player is not connected");
		} else return SendClientMessage(playerid,red,"ERROR: {FF00D9}You are not a high enough {FFFFFF}level {00FF40}to use this command");
	} else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}
Код:
CMD:osetlevel(playerid, params[]) {
            if(IsPlayerAdmin(playerid)) {
	        new string[128], tmp[128], tmp2[128], Index; tmp = strtok(params, Index), tmp2 = strtok(params, Index);
	        if(isnull(tmp) || isnull(tmp2)) return SendClientMessage(playerid, red, "USAGE: /osetlevel [playername] [level]");
	    	new level = strval(tmp2);
	    	if(!udb_Exists(PlayerName2(playerid))) {
		    new file[256];
			format(file, sizeof(file), "/ladmin/users/%s.ini", udb_encode(pName(playerid)));
			dUserSetINT(PlayerName2(playerid)).("level",(level));  //dUserSetINT(PlayerName2(player1)).("level",(level));   dUserSetINT(PlayerName2(playerid)), "Level", level);
			PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
    	    format(string, sizeof(string), "[INFO]: You have successfully set \"%s's\" level to %d", tmp, level);
    	    CMDMessageToAdmins(playerid, "OSETLEVEL");
			return SendClientMessage(playerid, blue, string);
		    } else return SendClientMessage(playerid, red, "ERROR: This player doesnt have an account");
	        } else return SendClientMessage(playerid, red, "ERROR: You are not a high enough level to use this command");
}
here's the register and login commands

Код:
CMD:register(playerid,params[])
{
    if (PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: You are already registered and logged in.");
    if (udb_Exists(PlayerName2(playerid))) return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: This account already exists, please use '/login [password]'.");
    if (strlen(params) == 0) return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: Correct usage: '/register [password]'");
    if (strlen(params) < 4 || strlen(params) > 20) return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: Password length must be greater than three characters");
    if (udb_Create(PlayerName2(playerid),params))
	{
    	new file[256],rname[MAX_PLAYER_NAME], tmp3[100];
    	new strdate[20], year,month,day;
		getdate(year, month, day);
		GetPlayerName(playerid,rname,sizeof(rname));
		format(file,sizeof(file),"/ladmin/users/%s.sav",udb_encode(rname));
     	GetPlayerIp(playerid,tmp3,100);
		dini_Set(file,"ip",tmp3);
//    	dini_Set(file,"password",params);
	    dUserSetINT(PlayerName2(playerid)).("registered",1);
   		format(strdate, sizeof(strdate), "%d/%d/%d",day,month,year);
		dini_Set(file,"RegisteredDate",strdate);
		dUserSetINT(PlayerName2(playerid)).("loggedin",1);
		dUserSetINT(PlayerName2(playerid)).("banned",0);
		dUserSetINT(PlayerName2(playerid)).("level",0);
	    dUserSetINT(PlayerName2(playerid)).("LastOn",0);
    	dUserSetINT(PlayerName2(playerid)).("money",0);
    	dUserSetINT(PlayerName2(playerid)).("kills",0);
	   	dUserSetINT(PlayerName2(playerid)).("deaths",0);
	   	dUserSetINT(PlayerName2(playerid)).("SS",0);
	   	dUserSetINT(PlayerName2(playerid)).("PK",0);
	   	dUserSetINT(PlayerName2(playerid)).("XX",0);
	   	dUserSetINT(PlayerName2(playerid)).("UK",0);
        dUserSetINT(PlayerName2(playerid)).("KOD",0);
        dUserSetINT(PlayerName2(playerid)).("DD",0);
        dUserSetINT(PlayerName2(playerid)).("MK",0);
        dUserSetINT(PlayerName2(playerid)).("SP",0);
   		dUserSetINT(PlayerName2(playerid)).("MI6",0);
   		dUserSetINT(PlayerName2(playerid)).("GTA",0);
   		dUserSetINT(PlayerName2(playerid)).("KH",0);
		dUserSetINT(PlayerName2(playerid)).("MM",0);
		dUserSetINT(PlayerName2(playerid)).("KH",0);
		dUserSetINT(PlayerName2(playerid)).("KF",0);
		dUserSetINT(PlayerName2(playerid)).("TT",0);
		dUserSetINT(PlayerName2(playerid)).("REIS",0);
		dUserSetINT(PlayerName2(playerid)).("GG",0);
		dUserSetINT(PlayerName2(playerid)).("LL",0);
		dUserSetINT(PlayerName2(playerid)).("LRC",0);
		dUserSetINT(PlayerName2(playerid)).("KOK",0);
		dUserSetINT(PlayerName2(playerid)).("SF",0);
		dUserSetINT(PlayerName2(playerid)).("SVNL",0);
		dUserSetINT(PlayerName2(playerid)).("Bank",PlayerInfo[playerid][bank]);
		dUserSetINT(PlayerName2(playerid)).("weed",PlayerInfo[playerid][weed]);
		dUserSetINT(PlayerName2(playerid)).("Gang",PlayerInfo[playerid][gang]);
		dUserSetINT(PlayerName2(playerid)).("Condoms",PlayerInfo[playerid][condoms]);
		dUserSetINT(PlayerName2(playerid)).("inalcatraz",PlayerInfo[playerid][inalcatraz]);
	    PlayerInfo[playerid][LoggedIn] = 1;
	    PlayerInfo[playerid][Registered] = 1;
	    SavePlayer(playerid);
		dUserSetINT(PlayerName2(playerid)).("bowner",0);
		dUserSetINT(PlayerName2(playerid)).("bowned",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowned",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowner",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowned2",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowner2",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowned3",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowner3",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowned4",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowner4",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowned5",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowner5",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowned6",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowner6",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowned7",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowner7",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowned8",0);
	   	dUserSetINT(PlayerName2(playerid)).("vowner8",0);
	   	dUserSetINT(PlayerName2(playerid)).("Houseid", -255);
		dUserSetINT(PlayerName2(playerid)).("Rentid", -255);
		dUserSetINT(PlayerName2(playerid)).("SpawnX", 0);
		dUserSetINT(PlayerName2(playerid)).("SpawnY", 0);
		dUserSetINT(PlayerName2(playerid)).("SpawnZ", 0);
		dUserSetINT(PlayerName2(playerid)).("SpawnInt", 0);
		LoginPlayer(playerid);
		LoadPlayer(playerid);
		SendClientMessage(playerid, green, "__________________________________________________________________________________________");
	    SendClientMessage(playerid, green, "ACCOUNT: {FA0C24}You are now {251BE0}registered, and have been {FAFA0C}automaticaly logged in {66FFFF}(Welcome)");
  		SendClientMessage(playerid, green, "__________________________________________________________________________________________");
	    GameTextForPlayer(playerid,"~b~Account succe~p~ssfully ~y~Regis~w~tered",5000,5);
		PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
		return 1;
	}
    return 1;
}
Код:
CMD:login(playerid,params[])
{
    if (PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: You are already logged in.");
    if (!udb_Exists(PlayerName2(playerid))) return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: Account doesn't exist, please use '/register [password]'.");
    if (strlen(params)==0) 	return SendClientMessage(playerid,COLOR_RED,"ACCOUNT: Correct usage: '/login [password]'");
    if (udb_CheckLogin(PlayerName2(playerid),params))
	{
	   	new file[256], tmp3[100], string[128], lname[MAX_PLAYER_NAME];
		GetPlayerName(playerid,lname,sizeof(lname));
	   	format(file,sizeof(file),"/ladmin/users/%s.sav",udb_encode(lname));
   		GetPlayerIp(playerid,tmp3,100);
	   	dini_Set(file,"ip",tmp3);
        LoginPlayer(playerid);
		LoadPlayer(playerid);
		PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
		if(PlayerInfo[playerid][Level] > 0) {
			format(string,sizeof(string),"ACCOUNT: {251BE0}Successfully Logged In. {66FFFF}(Level %d) {FAF623}(Welcome Back)", PlayerInfo[playerid][Level] );
			return SendClientMessage(playerid,green,string);
       	} else return SendClientMessage(playerid,green,"ACCOUNT: Successfully {FAFA0C}Logged In {0000CD}(Welcome)");
	}
	return ShowPlayerDialog(playerid, DIALOGID0+2, DIALOG_STYLE_INPUT, "{FA0C24}OPPSS!! Sorry", "{FFFFFF}WRONG Password, Try Again", "OK", "QUIT");
}

LoginPlayer(playerid)
{
	if(ServerInfo[GiveMoney] == 1) {ResetPlayerMoney(playerid); GivePlayerMoney(playerid, dUserINT(PlayerName2(playerid)).("money") ); }
	dUserSetINT(PlayerName2(playerid)).("loggedin",1);
	PlayerInfo[playerid][Deaths] = (dUserINT(PlayerName2(playerid)).("deaths"));
	PlayerInfo[playerid][Kills] = (dUserINT(PlayerName2(playerid)).("kills"));
 	PlayerInfo[playerid][Level] = (dUserINT(PlayerName2(playerid)).("level"));
	PlayerInfo[playerid][UK] = (dUserINT(PlayerName2(playerid)).("UK"));
 	PlayerInfo[playerid][PK] = (dUserINT(PlayerName2(playerid)).("PK"));
 	PlayerInfo[playerid][SS] = (dUserINT(PlayerName2(playerid)).("SS"));
 	PlayerInfo[playerid][DD] = (dUserINT(PlayerName2(playerid)).("ddlevel"));
	PlayerInfo[playerid][KOD] = (dUserINT(PlayerName2(playerid)).("KOD"));
 	PlayerInfo[playerid][XX] = (dUserINT(PlayerName2(playerid)).("XX"));
 	PlayerInfo[playerid][MK] = (dUserINT(PlayerName2(playerid)).("MK"));
	PlayerInfo[playerid][sp] = (dUserINT(PlayerName2(playerid)).("sp"));
	PlayerInfo[playerid][MI6] = (dUserINT(PlayerName2(playerid)).("MI6"));
	PlayerInfo[playerid][GTA] = (dUserINT(PlayerName2(playerid)).("GTA"));
	PlayerInfo[playerid][KH] = (dUserINT(PlayerName2(playerid)).("KH"));
	PlayerInfo[playerid][MM] = (dUserINT(PlayerName2(playerid)).("MM"));
	PlayerInfo[playerid][KF] = (dUserINT(PlayerName2(playerid)).("KF"));
 	PlayerInfo[playerid][TT] = (dUserINT(PlayerName2(playerid)).("TT"));
 	PlayerInfo[playerid][REIS] = (dUserINT(PlayerName2(playerid)).("REIS"));
 	PlayerInfo[playerid][GG] = (dUserINT(PlayerName2(playerid)).("GG"));
	PlayerInfo[playerid][LL] = (dUserINT(PlayerName2(playerid)).("LL"));
	PlayerInfo[playerid][LRC] = (dUserINT(PlayerName2(playerid)).("LRCLevel"));
	PlayerInfo[playerid][KOK] = (dUserINT(PlayerName2(playerid)).("KOK"));
	PlayerInfo[playerid][SF] = (dUserINT(PlayerName2(playerid)).("SF"));
	PlayerInfo[playerid][SF] = (dUserINT(PlayerName2(playerid)).("SVNL"));
	PlayerInfo[playerid][Registered] = 1;
 	PlayerInfo[playerid][LoggedIn] = 1;
}
Reply
#2

help?
Reply
#3

You can look where the error starts to appear.

First look in the User File, what value is stored there.

If it is wrong there, the error must be the save.

If the value is correct, the error must be in the loading.

Easy as that
Reply
#4

but there's not errors when i compile it
Reply
#5

I would recommend you update the system that you're using. I recommend y_ini or looking into SQL/SQLite. dini is pretty outdated and, personally, very frustrating to use.

y_ini: https://sampforum.blast.hk/showthread.php?tid=570957
SQL: https://sampforum.blast.hk/showthread.php?tid=56564
Reply
#6

You should really look into using sscanf miles easier.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)