Admin Script
#1

Hey Guys, I recently made a Admin script, but there is a probleam with the registerion.
When a player registers it saves his file into scriptfiles > Players, but when he rejoins, it tells him to register again, and resets all his stats, Here is my registarion command:


pawn Код:
public OnPlayerConnect(playerid)
{
    gPlayerLogged[playerid] = 0;
    new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), MafiaAdmin, name);
    dini_IntSet(file, "Warns",PlayerInfo[playerid][pWarns] = 1);
    if (!dini_Exists(file))
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "You Are Not Registerd", "Welcome, you are not registered, please, input your registration password below", "Register", "Leave");
    }
    if(fexist(file))
    {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You Are Registerd", "Your account is registered! Now type your password below.", "Login", "Leave");
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), MafiaAdmin, name);
    if(gPlayerLogged[playerid] == 1)
    {
        PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
        dini_IntSet(file, "Score", PlayerInfo[playerid][pScore]);
        dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]);
        dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel]);
        dini_IntSet(file, "Warns",1);
        dini_IntSet(file, "Banned",PlayerInfo[playerid][pBanned]);
        dini_IntSet(file, "Muted",PlayerInfo[playerid][pMuted]);
        dini_IntSet(file, "Jailed",PlayerInfo[playerid][pJailed]);
    }
    gPlayerLogged[playerid] = 0;
    return 1;
}

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), MafiaAdmin, name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "You are not registered.", "Welcome, your not registered, please, input your registration password below", "Register", "Leave");
        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] = 5000);
        dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0);
        dini_IntSet(file, "Warns",PlayerInfo[playerid][pWarns] = 1);
        dini_IntSet(file, "Banned",PlayerInfo[playerid][pBanned] = 0);
        dini_IntSet(file, "Muted",PlayerInfo[playerid][pMuted] = 0);
        dini_IntSet(file, "Jailed",PlayerInfo[playerid][pJailed] = 0);
        format(string, 128, "You have succesfully registered the nickname %s with password %s, you have been auto logged in.", name, inputtext);
        SendClientMessage(playerid, COLOR_YELLOW, string);
        gPlayerLogged[playerid] = 1;
    }
    if (dialogid == 2)
    {
        new name[MAX_PLAYER_NAME], file[256];
        GetPlayerName(playerid, name, sizeof(name));
        format(file, sizeof(file), MafiaAdmin, name);
        if(!response) return Kick(playerid);
        if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered", "Please input your password below.", "Login", "Leave");
        new tmp;
        tmp = dini_Int(file, "Password");
        if(udb_hash(inputtext) != tmp) {
            SendClientMessage(playerid, COLOR_RED, "Incorrect password. Please try again.");
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You are registered.", "Please input your password below.", "Login", "Leave");
        }
        else
        {
            gPlayerLogged[playerid] = 1;
            PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
            SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
            GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
            SendClientMessage(playerid,COLOR_RED, "You have successfully logged in!");
        }
    }
    return 1;
}
And I have this definded:

pawn Код:
#define MafiaAdmin "Players/%s.ini"
Reply
#2

wierd
but the only not normal thing I can see is

you got this
pawn Код:
if (!strlen(inputtext)) return
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "You are not registered.", "Welcome, your not registered, please, input your registration password below", "Register", "Leave");
and after that alot of codes

then it will return all of that
just replace it with

pawn Код:
if (!strlen(inputtext)) return        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "You are not registered.", "Welcome, your not registered, please, input your registration password below", "Register", "Leave");
and I know im sounding like a lame scripter
or a noob
but thats really the only thing I can see
Reply
#3

I replaced it, complied, didint get errors/warrnings but it still dosen't work -.-
Reply
#4

Bump
Reply
#5

Change this:
pawn Код:
if (!dini_Exists(file))
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "You Are Not Registerd", "Welcome, you are not registered, please, input your registration password below", "Register", "Leave");
    }
    if(fexist(file))
    {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You Are Registerd", "Your account is registered! Now type your password below.", "Login", "Leave");
    }
TO:
pawn Код:
if(!dini_Exists(file))
{
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "You Are Not Registerd", "Welcome, you are not registered, please, input your registration password below", "Register", "Leave");
}
else
{
    ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "You Are Registerd", "Your account is registered! Now type your password below.", "Login", "Leave");
}
Reply
#6

I get one warrning

pawn Код:
C:\Users\MarioG\Desktop\SASP\filterscripts\MafiaAdmin.pwn(193) : warning 217: loose indentation
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.
Line 193:
pawn Код:
if(!dini_Exists(file))
Reply
#7

This fixes that warning
#define tabsize 0

The warning means your code isn't aligned with the other lines-.-
Reply
#8

Well, that fixed the warrning, and now I got no errors/warrning, but still when I register and rejoin, it tells me to register again -.-
Reply
#9

Quote:
Originally Posted by ikkentim
Посмотреть сообщение
This fixes that warning
#define tabsize 0

The warning means your code isn't aligned with the other lines-.-
Stop saying people to use tabsize 0! FFS just indent your damn code! It ain't hard.

If you don't know how to indent, Wiki >> Warnings list.
Reply
#10

code idented:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext,"/youcommand", true))
    {
        return 1;
    }
    return 0;
}

code don't idented and don't recomended:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext,"/youcommand", true))
{
return 1;
}
return 0;
}
appers erros,
Код:
loose identation
Not recomended:
Not use '#pragma tabsize 0'
using this, you stay programing bad mode.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)