Saving system + commands.
#1

Hello, I am a beginner in scripting and I recently made a login system. I followed the tutorial from Lorenc_ (http://forum.sa-mp.com/showthread.ph...=Saving+system)

I followed everything, and everything works fine. Dialogs shows up and stuff. But when I typ a random password I still login. The "You have typted the incorrect password" message should show up. But it doesn't. My account will be stored in my scriptfiles called ''myserver'' as used in the script. When I edit my score to something like 5, I does not happen ingame. Neither my admin level does while it is all in my enum.

Question 2, I made a /makeadmin command with zcmd. But I can't make myself admin even when I login into the rcon. It says I am not high enough to use the command. While I am admin level 1337 in the saving system.

Script:

pawn Код:
CMD:makeadmin(playerid,params[])
{
    if(PlayerInfo[playerid][pAdminLevel] >= 1337) //the one who typed it
    {
        new string[128],name[MAX_PLAYER_NAME],pID,Level;
        GetPlayerName(playerid,name,MAX_PLAYER_NAME);
        if(sscanf(params,"ui",pID,Level)) return SendClientMessage(playerid,COLOR_RED,"/makeadmin <player> <level>");
        if(IsPlayerConnected(pID))
        {
            if(PlayerInfo[pID][pAdminLevel] != Level) //why not let RCON admins have admin...?
            {
                PlayerInfo[pID][pAdminLevel] = Level;
                format(string,sizeof(string),"%s has been promoted to Admin Level %d!",name,Level);
                SendClientMessageToAll(COLOR_BLUE,string);
                GameTextForPlayer(pID,"Promoted",3000,4);
            }
            else return SendClientMessage(playerid, COLOR_RED, "This player is already that level.");
        }
        else return SendClientMessage(playerid, COLOR_RED, "Invalid Player Specified.");
    }
    else return SendClientMessage(playerid, COLOR_RED, "You don't have access to this command.");
    return 1;
}
Saving system:

pawn Код:
//--------------------------ENUMS----------------------------

enum pInfo
{
    pAdminLevel,
    pCash,
    pScore,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
new gPlayerLogged[MAX_PLAYERS];

//-------------------------------------------------------------
pawn Код:
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, 1, DIALOG_STYLE_INPUT, "Login Dialog", "You are not registered yet. Please register to continue.", "Register", "Play");
    }
    if(fexist(file))
    {
    ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login Dialog", "You are already registered, please login to continue.", "Login", "Play");
    }
    return 1;
}
pawn Код:
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;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == 1)
    {
        new name[MAX_PLAYER_NAME], file[256], string[128];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), SERVER_USER_FILE, name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Login Dialog", "Welcome, you are not registered. Please register below.", "Register", "Play");
        dini_Create(file);
        dini_IntSet(file, "Password", udb_hash(inputtext));
        dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel] = 0);
        dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 500);
        dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0);
        format(string, 128, "You have succesfully registered. Enjoy your stay!", name, inputtext);
        SendClientMessage(playerid, COLOR_RED, string);
        gPlayerLogged[playerid] = 1;
        }
return 1;
    }
Reply
#2

Check your script files maybe the folders there are not correct or inside the script change the folder.
Reply
#3

Quote:
Originally Posted by SampN
Посмотреть сообщение
Check your script files maybe the folders there are not correct or inside the script change the folder.
No, the scriptfiles are correct. My username is stored inside the map. But when I adjust things like my score, it doesn't change in-game.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)