[Ajuda] Nгo Estб Salvando Score e money
#1

Olб galera , eu estou com um problema no meu server tudo estб salvando ok , menos o dinheiro e o score. Ele nгo altera o q ta escrito no arquivo quando eu saio do server ! .
Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#include <dini>
#include <dutils>
#pragma unused ret_memcpy
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define PlayerFile "Admin/Users/%s.ini"
#define CommandFile "Admin/Settings/Commands.ini"


#if defined FILTERSCRIPT

#endif


enum PLAYER_MAIN
{
    PLAYER_NAME[MAX_PLAYER_NAME],
    PLAYER_IP[16],
    PLAYER_REGGED,
    PLAYER_PASS,
    PLAYER_LEVEL,
    PLAYER_MONEY,
    PLAYER_SCORE,
}
new gPlayerInfo[MAX_PLAYERS][PLAYER_MAIN];
new gPlayerLogged[MAX_PLAYERS];

enum COMMANDS_MAIN {
    KICK,
    BAN
}
new gCommands[COMMANDS_MAIN];

public OnFilterScriptInit()
{

    // Level 0 = Noob
    // Level 1 = Trusted Player
    // Level 2 = Member
    // Level 3 = Moderator
    // Level 4 = Administrator
    // Level 5 = Server owner

    if(!fexist(CommandFile))
    {
        dini_Create(CommandFile);
        dini_IntSet(CommandFile, "Kick", 3);
        dini_IntSet(CommandFile, "Ban", 3);
    }

    gCommands[KICK] = dini_Int(CommandFile, "Kick");
    gCommands[BAN] = dini_Int(CommandFile, "Ban");
    return 1;
}
public OnPlayerConnect(playerid)
{
    new file[100], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), PlayerFile, name);
    if(!fexist(file))
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "~ Registro ~", " Digite a senha para o cadastro. ", "Registro", "Sair");
    }
    else if(fexist(file))
    {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "~ Login ~", " Digite sua senha. ", "Login", "Sair");
    }
    return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
    new file[100];
    format(file, sizeof(file), PlayerFile, gPlayerInfo[playerid][PLAYER_NAME]);
    dini_Set(file, "Name", gPlayerInfo[playerid][PLAYER_NAME]);
    dini_Set(file, "Ip", gPlayerInfo[playerid][PLAYER_IP]);
    dini_IntSet(file, "Registered", gPlayerInfo[playerid][PLAYER_REGGED]);
    dini_IntSet(file, "Password", gPlayerInfo[playerid][PLAYER_PASS]);
    dini_IntSet(file, "Level", gPlayerInfo[playerid][PLAYER_LEVEL]);
    dini_IntSet(file, "Money",GetPlayerMoney(playerid));
    dini_IntSet(file, "Score", GetPlayerScore(playerid));

	gPlayerLogged[playerid] = 0;
    return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1)
    {
        if(response)
        {
            if(strlen(inputtext))
            {
                new file[100], name[MAX_PLAYER_NAME], ip[16], string[128];
                GetPlayerName(playerid, name, sizeof(name));
                GetPlayerIp(playerid, ip, sizeof(ip));
                format(file, sizeof(file), PlayerFile, name);
                dini_Create(file);
                dini_Set(file, "Name", name);
                dini_Set(file, "Ip", ip);
                dini_IntSet(file, "Registered", 1);
                dini_IntSet(file, "Password", num_hash(inputtext));
                dini_IntSet(file, "Level", 0);
                dini_IntSet(file, "Money", 123456);
                dini_IntSet(file, "Score", 1);
                format(string, sizeof(string), "[Server] Vocк acaba de se registrar como %s.", name);
                SendClientMessage(playerid, 0xFFFFFFFF, string);
                strcat(gPlayerInfo[playerid][PLAYER_NAME], dini_Get(file, "Name"));
                strcat(gPlayerInfo[playerid][PLAYER_IP], dini_Get(file, "Ip"));
                gPlayerInfo[playerid][PLAYER_PASS] = dini_Int(file, "Password");
                gPlayerInfo[playerid][PLAYER_LEVEL] = dini_Int(file, "Level");
                SetPlayerScore(playerid, dini_Int(file, "Score"));
                GivePlayerMoney(playerid, dini_Int(file, "Money"));
                gPlayerLogged[playerid] = 1;
            }
            else if(!strlen(inputtext))
            {
                SendClientMessage(playerid, 0xFF1212FF, "[Server] Coloque a senha !");
                ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Registro", "Digite a senha para o cadastro.", "Registrar-se ", "Sair");
            }
        }
        else if(!response)
        {
            SendClientMessage(playerid, 0xFF1212FF, "[Server] Vocк precisa estar cadastro para jogar !");
            Kick(playerid);
        }
    }

    if(dialogid == 2)
    {
        if(response)
        {
            if(strlen(inputtext))
            {
                new file[100], name[MAX_PLAYER_NAME], string[128];
                GetPlayerName(playerid, name, sizeof(name));
                format(file, sizeof(file), PlayerFile, name);
                if(num_hash(inputtext) == dini_Int(file, "Password"))
                {
                    strcat(gPlayerInfo[playerid][PLAYER_NAME], dini_Get(file, "Name"));
                    strcat(gPlayerInfo[playerid][PLAYER_IP], dini_Get(file, "Ip"));
                    gPlayerInfo[playerid][PLAYER_PASS] = dini_Int(file, "Password");
                    gPlayerInfo[playerid][PLAYER_LEVEL] = dini_Int(file, "Level");
                    gPlayerInfo[playerid][PLAYER_MONEY] = GivePlayerMoney(playerid, dini_Int(file, "Money"));
                    gPlayerInfo[playerid][PLAYER_SCORE] = SetPlayerScore(playerid, dini_Int(file, "Score"));
                    gPlayerLogged[playerid] = 1;
                    ResetPlayerMoney(playerid);
			      	SetPlayerScore(playerid, dini_Int(file, "Score"));
					GivePlayerMoney(playerid, dini_Int(file, "Money"));
                    format(string, sizeof(string), "[Server] Bem Vindo de Volta, %s", name);
                    SendClientMessage(playerid, 0xFFFFFFFF, string);
                }
                else if(num_hash(inputtext) != dini_Int(file, "Password"))
                {
                    SendClientMessage(playerid, 0xFF1212FF, "[Server] Senha Incorreta!");
                    ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "Digite sua senha.", "Login", "Sair");
                }
            }
            else if(!strlen(inputtext))
            {
                SendClientMessage(playerid, 0xFF1212FF, "[Servidor] Digita sua senha!");
                ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "Digite sua senha.", "Login", "Sair");
            }
        }
        else if(!response)
        {
            SendClientMessage(playerid, 0xFF1212FF, "[Server] Vocк precisa estar logado para jogar !");
            Kick(playerid);
        }
    }
    return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(kick, 4, cmdtext);
    dcmd(ban, 3, cmdtext);
    return 0;
}
dcmd_kick(playerid, params[])
{
    if(gPlayerInfo[playerid][PLAYER_LEVEL] < gCommands[KICK])
    {
        new string[128];
        format(string, sizeof(string), "Vocк Precisa ser %d de ADM para usar este comando!", gCommands[KICK]);
        SendClientMessage(playerid, 0xFF1212FF , string);
    }
    else
    {
        new tmp[256], tmp2[256], index, id;
        tmp = strtok(params, index);
        tmp2 = strtok(params, index);

        if(!strlen(tmp))
        {
            SendClientMessage(playerid, 0xFF1212FF , "[KICK] Modo de utilizaзгo: /kick [ID] [Razгo]");
        }
        else if(!strlen(tmp2))
        {
            SendClientMessage(playerid, 0xFF1212FF , "[KICK] Modo de utilizaзгo: /kick [ID] [Razгo]");
        }
        else
        {
            id = strval(tmp);
            if(!IsPlayerConnected(id))
            {
                SendClientMessage(playerid, 0xFF1212FF , "[KICK] Esse Player nгo estб conectado");
            }
            else if(id == playerid)
            {
                SendClientMessage(playerid, 0xFF1212FF , "[KICK] Vocк nгo pode se kickar");
            }
            else if(gPlayerInfo[id][PLAYER_LEVEL] > gPlayerInfo[playerid][PLAYER_LEVEL])
            {
                SendClientMessage(playerid, 0xFF1212FF , "[KICK] Esse player tem um nнvel maior que o seu.");
            }
            else
            {
                new string[256], name[MAX_PLAYER_NAME];
                GetPlayerName(id, name, sizeof(name));
                if(id >= 0 && id <= 9)
                {
                    format(string, sizeof(string), "[KICK] Vocк foi kickado. Razгo: %s.", params[2]);
                    SendClientMessage(id, 0xFF1212FF , string);
                    Kick(id);
                    format(string, sizeof(string), "[KICK] O player %s foi kickado. Razгo: %s.", name, params[2]);
                    SendClientMessageToAll(0xFF1212FF , string);
                }
                else if(id >= 10 && id <= 99)
                {
                    format(string, sizeof(string), "[[KICK] Vocк foi kickado. Razгo: %s.", params[3]);
                    SendClientMessage(id, 0xFF1212FF , string);
                    Kick(id);
                    format(string, sizeof(string), "[KICK] O player %s foi kickado. Razгo: %s.", name, params[3]);
                    SendClientMessageToAll(0xFF1212FF , string);
                }
            }
        }
    }
    return 1;
}
dcmd_ban(playerid, params[])
{
    if(gPlayerInfo[playerid][PLAYER_LEVEL] < gCommands[KICK])
    {
        new string[128];
        format(string, sizeof(string), "Vocк Precisa ser %d de ADM para usar este comando!", gCommands[KICK]);
        SendClientMessage(playerid, 0xFF1212FF , string);
    }
    else
    {
        new tmp[256], tmp2[256], index, id;
        tmp = strtok(params, index);
        tmp2 = strtok(params, index);

        if(!strlen(tmp))
        {
            SendClientMessage(playerid, 0xFF1212FF , "[BAN] Modo de utilizaзгo: /ban [ID] [Razгo]");
        }
        else if(!strlen(tmp2))
        {
            SendClientMessage(playerid, 0xFF1212FF , "[BAN] Modo de utilizaзгo: /ban [ID] [Razгo]");
        }
        else
        {
            id = strval(tmp);
            if(!IsPlayerConnected(id))
            {
                SendClientMessage(playerid, 0xFF1212FF , "[BAN] Esse Player nгo estб conectado");
            }
            else if(id == playerid)
            {
                SendClientMessage(playerid, 0xFF1212FF , "[BAN] Vocк nгo pode banir vocк mesmo.");
            }
            else if(gPlayerInfo[id][PLAYER_LEVEL] > gPlayerInfo[playerid][PLAYER_LEVEL])
            {
                SendClientMessage(playerid, 0xFF1212FF , "[BAN] Este player tem um nнvel maior que o seu.");
            }
            else
            {
                new string[256], name[MAX_PLAYER_NAME];
                GetPlayerName(id, name, sizeof(name));
                if(id >= 0 && id <= 9)
                {
                    format(string, sizeof(string), "[BAN] Vocк foi banido. Razгo: %s.", params[2]);
                    SendClientMessage(id, 0xFF1212FF , string);
                    Kick(id);
                    format(string, sizeof(string), "[BAN] O Player %s foi banido. Razгo: %s.", name, params[2]);
                    SendClientMessageToAll(0xFF1212FF , string);
                }
                else if(id >= 10 && id <= 99)
                {
                    format(string, sizeof(string), "[BAN] Vocк foi banido. Razгo: %s.", params[3]);
                    SendClientMessage(id, 0xFF1212FF , string);
                    Kick(id);
                    format(string, sizeof(string), "[BAN] O Player %s foi banido. Razгo: %s.", name, params[3]);
                    SendClientMessageToAll(0xFF1212FF , string);
                }
            }
        }
    }
    return 1;
}
Reply
#2

Tente isso:
pawn Код:
new file[100];
    new dinheiro = GetPlayerMoney(playerid);
    new score = GetPlayerScore(playerid);
    format(file, sizeof(file), PlayerFile, gPlayerInfo[playerid][PLAYER_NAME]);
    dini_Set(file, "Name", gPlayerInfo[playerid][PLAYER_NAME]);
    dini_Set(file, "Ip", gPlayerInfo[playerid][PLAYER_IP]);
    dini_IntSet(file, "Registered", gPlayerInfo[playerid][PLAYER_REGGED]);
    dini_IntSet(file, "Password", gPlayerInfo[playerid][PLAYER_PASS]);
    dini_IntSet(file, "Level", gPlayerInfo[playerid][PLAYER_LEVEL]);
    dini_IntSet(file, "Money",dinheiro);
    dini_IntSet(file, "Score", score);
Reply
#3

Quote:
Originally Posted by Heisen
Посмотреть сообщение
Tente isso:
pawn Код:
new file[100];
    new dinheiro = GetPlayerMoney(playerid);
    new score = GetPlayerScore(playerid);
    format(file, sizeof(file), PlayerFile, gPlayerInfo[playerid][PLAYER_NAME]);
    dini_Set(file, "Name", gPlayerInfo[playerid][PLAYER_NAME]);
    dini_Set(file, "Ip", gPlayerInfo[playerid][PLAYER_IP]);
    dini_IntSet(file, "Registered", gPlayerInfo[playerid][PLAYER_REGGED]);
    dini_IntSet(file, "Password", gPlayerInfo[playerid][PLAYER_PASS]);
    dini_IntSet(file, "Level", gPlayerInfo[playerid][PLAYER_LEVEL]);
    dini_IntSet(file, "Money",dinheiro);
    dini_IntSet(file, "Score", score);
Nгo funfou , continua nгo salvando !
Reply
#4

UP ? Alguйm pode me ajudar ? nгo funcionou eu substitui no onplayerdisconnect
Reply
#5

Parзa eu atй abrir pra te ajudar, sу que porque nгo usa dof2 muito mais prбtico e rбpido.
Reply
#6

Quote:
Originally Posted by Caiton
Посмотреть сообщение
Parзa eu atй abrir pra te ajudar, sу que porque nгo usa dof2 muito mais prбtico e rбpido.
Cara nгo posta sу para dizer isto fera,tente pelo menos.

Bom vocк poderia criar 2 stock,pode consumir mais,sу que funciona no meu GM.

pawn Код:
stock ArquivoSalvar(playerid)
{
    new, Nome[MAX_PLAYER_NAME], Arquivo[128];
    GetPlayerName(playerid, Nome, sizeof(Nome));
    format(Arquivo, sizeof(Arquivo), "/Contas/%s.ini", Nome);//Altera o Diretуrio aqui se for diferente
    return Arquivo;
}

stock SalvarArquivo(playerid)
{
    new file[100];
    format(file, sizeof(file), ArquivoSalvar, gPlayerInfo[playerid][PLAYER_NAME]);
    dini_Set(file, "Name", gPlayerInfo[playerid][PLAYER_NAME]);
    dini_Set(file, "Ip", gPlayerInfo[playerid][PLAYER_IP]);
    dini_IntSet(file, "Registered", gPlayerInfo[playerid][PLAYER_REGGED]);
    dini_IntSet(file, "Password", gPlayerInfo[playerid][PLAYER_PASS]);
    dini_IntSet(file, "Level", gPlayerInfo[playerid][PLAYER_LEVEL]);
    dini_IntSet(file, "Money",GetPlayerMoney(playerid));
    dini_IntSet(file, "Score", GetPlayerScore(playerid));
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    SalvarArquivo(playerid);
    return 1;
}
Mas eu realmente espero que vocк aprenda usar y_ini ou DOF2, sгo bem mais rбpidos e prбticos!

PS:: Eu faзo naquele modelo assim quando estou a usar y_ini, portanto nгo sei como й em Dini(nunca usei).
Reply
#7

Tente:

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(gPlayerLogged[playerid]){

        new file[100];
        format(file, sizeof(file), PlayerFile, gPlayerInfo[playerid][PLAYER_NAME]);
        dini_Set(file, "Name", gPlayerInfo[playerid][PLAYER_NAME]);
        dini_Set(file, "Ip", gPlayerInfo[playerid][PLAYER_IP]);
        dini_IntSet(file, "Registered", gPlayerInfo[playerid][PLAYER_REGGED]);
        dini_IntSet(file, "Password", gPlayerInfo[playerid][PLAYER_PASS]);
        dini_IntSet(file, "Level", gPlayerInfo[playerid][PLAYER_LEVEL]);
        dini_IntSet(file, "Money",GetPlayerMoney(playerid));
        dini_IntSet(file, "Score", GetPlayerScore(playerid));
    }

    gPlayerLogged[playerid] = 0;
    return 1;
}
Reply
#8

Quote:
Originally Posted by ForT
Посмотреть сообщение
Tente:

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(gPlayerLogged[playerid]){

        new file[100];
        format(file, sizeof(file), PlayerFile, gPlayerInfo[playerid][PLAYER_NAME]);
        dini_Set(file, "Name", gPlayerInfo[playerid][PLAYER_NAME]);
        dini_Set(file, "Ip", gPlayerInfo[playerid][PLAYER_IP]);
        dini_IntSet(file, "Registered", gPlayerInfo[playerid][PLAYER_REGGED]);
        dini_IntSet(file, "Password", gPlayerInfo[playerid][PLAYER_PASS]);
        dini_IntSet(file, "Level", gPlayerInfo[playerid][PLAYER_LEVEL]);
        dini_IntSet(file, "Money",GetPlayerMoney(playerid));
        dini_IntSet(file, "Score", GetPlayerScore(playerid));
    }

    gPlayerLogged[playerid] = 0;
    return 1;
}
Quote:
Originally Posted by PedexM
Посмотреть сообщение
Cara nгo posta sу para dizer isto fera,tente pelo menos.

Bom vocк poderia criar 2 stock,pode consumir mais,sу que funciona no meu GM.

pawn Код:
stock ArquivoSalvar(playerid)
{
    new, Nome[MAX_PLAYER_NAME], Arquivo[128];
    GetPlayerName(playerid, Nome, sizeof(Nome));
    format(Arquivo, sizeof(Arquivo), "/Contas/%s.ini", Nome);//Altera o Diretуrio aqui se for diferente
    return Arquivo;
}

stock SalvarArquivo(playerid)
{
    new file[100];
    format(file, sizeof(file), ArquivoSalvar, gPlayerInfo[playerid][PLAYER_NAME]);
    dini_Set(file, "Name", gPlayerInfo[playerid][PLAYER_NAME]);
    dini_Set(file, "Ip", gPlayerInfo[playerid][PLAYER_IP]);
    dini_IntSet(file, "Registered", gPlayerInfo[playerid][PLAYER_REGGED]);
    dini_IntSet(file, "Password", gPlayerInfo[playerid][PLAYER_PASS]);
    dini_IntSet(file, "Level", gPlayerInfo[playerid][PLAYER_LEVEL]);
    dini_IntSet(file, "Money",GetPlayerMoney(playerid));
    dini_IntSet(file, "Score", GetPlayerScore(playerid));
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    SalvarArquivo(playerid);
    return 1;
}
Mas eu realmente espero que vocк aprenda usar y_ini ou DOF2, sгo bem mais rбpidos e prбticos!

PS:: Eu faзo naquele modelo assim quando estou a usar y_ini, portanto nгo sei como й em Dini(nunca usei).
Nгo funfou cara
Reply
#9

Alguйm mais pode me ajudar ?
Reply
#10

Meu cуdigo estб assim atualmente , e eu gostaria de criar outros comandos e relsolver o problema do nгo salvamento do score e do dinheiro !!


Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#include <dini>
#include <dutils>
#pragma unused ret_memcpy
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define PlayerFile "Admin/Users/%s.ini"
#define CommandFile "Admin/Settings/Commands.ini"
#if defined FILTERSCRIPT

#endif


enum PLAYER_MAIN
{
    PLAYER_NAME[MAX_PLAYER_NAME],
    PLAYER_IP[16],
    PLAYER_REGGED,
    PLAYER_PASS,
    PLAYER_LEVEL,
    PLAYER_MONEY,
    PLAYER_SCORE,
}
new gPlayerInfo[MAX_PLAYERS][PLAYER_MAIN];
new gPlayerLogged[MAX_PLAYERS];

enum COMMANDS_MAIN {
    KICK,
    BAN
}
new gCommands[COMMANDS_MAIN];
stock ArquivoSalvar(playerid)
{
    new, Nome[MAX_PLAYER_NAME], Arquivo[128];
    GetPlayerName(playerid, Nome, sizeof(Nome));
    format(Arquivo, sizeof(Arquivo), "Admin/Users/%s.ini", Nome);//Altera o Diretуrio aqui se for diferente
    return Arquivo;
}

stock SalvarArquivo(playerid)
{
    new file[100];
    format(file, sizeof(file), PlayerFile , gPlayerInfo[playerid][PLAYER_NAME]);
    dini_Set(file, "Name",gPlayerInfo[playerid][PLAYER_NAME]);
    dini_Set(file, "Ip", gPlayerInfo[playerid][PLAYER_IP]);
    dini_IntSet(file, "Registered", gPlayerInfo[playerid][PLAYER_REGGED]);
    dini_IntSet(file, "Password", gPlayerInfo[playerid][PLAYER_PASS]);
    dini_IntSet(file, "Level", gPlayerInfo[playerid][PLAYER_LEVEL]);
    dini_IntSet(file, "Money",GetPlayerMoney(playerid));
    dini_IntSet(file, "Score", GetPlayerScore(playerid));
    return 1;
}
public OnFilterScriptInit()
{

    // Level 0 = Noob
    // Level 1 = Trusted Player
    // Level 2 = Member
    // Level 3 = Moderator
    // Level 4 = Administrator
    // Level 5 = Server owner

    if(!fexist(CommandFile))
    {
        dini_Create(CommandFile);
        dini_IntSet(CommandFile, "Kick", 3);
        dini_IntSet(CommandFile, "Ban", 3);
    }

    gCommands[KICK] = dini_Int(CommandFile, "Kick");
    gCommands[BAN] = dini_Int(CommandFile, "Ban");
    return 1;
}
public OnPlayerConnect(playerid)
{
    new file[100], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), PlayerFile, name);
    if(!fexist(file))
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "~ Registro ~", " Digite a senha para o cadastro. ", "Registro", "Sair");
    }
    else if(fexist(file))
    {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "~ Login ~", " Digite sua senha. ", "Login", "Sair");
    }
    return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
	SalvarArquivo(playerid);
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 1)
    {
        if(response)
        {
            if(strlen(inputtext))
            {
                new file[100], name[MAX_PLAYER_NAME], ip[16], string[128];
                GetPlayerName(playerid, name, sizeof(name));
                GetPlayerIp(playerid, ip, sizeof(ip));
                format(file, sizeof(file), PlayerFile, name);
                dini_Create(file);
                dini_Set(file, "Name", name);
                dini_Set(file, "Ip", ip);
                dini_IntSet(file, "Registered", 1);
                dini_IntSet(file, "Password", num_hash(inputtext));
                dini_IntSet(file, "Level", 0);
                dini_IntSet(file, "Money", 123456);
                dini_IntSet(file, "Score", 1);
                format(string, sizeof(string), "[Server] Vocк acaba de se registrar como %s.", name);
                SendClientMessage(playerid, 0xFFFFFFFF, string);
                strcat(gPlayerInfo[playerid][PLAYER_NAME], dini_Get(file, "Name"));
                strcat(gPlayerInfo[playerid][PLAYER_IP], dini_Get(file, "Ip"));
                gPlayerInfo[playerid][PLAYER_PASS] = dini_Int(file, "Password");
                gPlayerInfo[playerid][PLAYER_LEVEL] = dini_Int(file, "Level");
                SetPlayerScore(playerid, dini_Int(file, "Score"));
                GivePlayerMoney(playerid, dini_Int(file, "Money"));
                gPlayerLogged[playerid] = 1;
            }
            else if(!strlen(inputtext))
            {
                SendClientMessage(playerid, 0xFF1212FF, "[Server] Coloque a senha !");
                ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Registro", "Digite a senha para o cadastro.", "Registrar-se ", "Sair");
            }
        }
        else if(!response)
        {
            SendClientMessage(playerid, 0xFF1212FF, "[Server] Vocк precisa estar cadastro para jogar !");
            Kick(playerid);
        }
    }

    if(dialogid == 2)
    {
        if(response)
        {
            if(strlen(inputtext))
            {
                new file[100], name[MAX_PLAYER_NAME], string[128];
                GetPlayerName(playerid, name, sizeof(name));
                format(file, sizeof(file), PlayerFile, name);
                if(num_hash(inputtext) == dini_Int(file, "Password"))
                {
                    strcat(gPlayerInfo[playerid][PLAYER_NAME], dini_Get(file, "Name"));
                    strcat(gPlayerInfo[playerid][PLAYER_IP], dini_Get(file, "Ip"));
                    gPlayerInfo[playerid][PLAYER_PASS] = dini_Int(file, "Password");
                    gPlayerInfo[playerid][PLAYER_LEVEL] = dini_Int(file, "Level");
                    gPlayerInfo[playerid][PLAYER_MONEY] = GivePlayerMoney(playerid, dini_Int(file, "Money"));
                    gPlayerInfo[playerid][PLAYER_SCORE] = SetPlayerScore(playerid, dini_Int(file, "Score"));
                    gPlayerLogged[playerid] = 1;
                    ResetPlayerMoney(playerid);
         			SetPlayerScore(playerid, dini_Int(file, "Score"));
    				GivePlayerMoney(playerid, dini_Int(file, "Money"));
                    format(string, sizeof(string), "[Server] Bem Vindo de Volta, %s", name);
                    SendClientMessage(playerid, 0xFFFFFFFF, string);
                }
                else if(num_hash(inputtext) != dini_Int(file, "Password"))
                {
                    SendClientMessage(playerid, 0xFF1212FF, "[Server] Senha Incorreta!");
                    ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "Digite sua senha.", "Login", "Sair");
                }
            }
            else if(!strlen(inputtext))
            {
                SendClientMessage(playerid, 0xFF1212FF, "[Servidor] Digita sua senha!");
                ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Login", "Digite sua senha.", "Login", "Sair");
            }
        }
        else if(!response)
        {
            SendClientMessage(playerid, 0xFF1212FF, "[Server] Vocк precisa estar logado para jogar !");
            Kick(playerid);
        }
    }
    return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(kick, 4, cmdtext);
    dcmd(ban, 3, cmdtext);
    return 0;
}
dcmd_kick(playerid, params[])
{
    if(gPlayerInfo[playerid][PLAYER_LEVEL] < gCommands[KICK])
    {
        new string[128];
        format(string, sizeof(string), "Vocк Precisa ser %d de ADM para usar este comando!", gCommands[KICK]);
        SendClientMessage(playerid, 0xFF1212FF , string);
    }
    else
    {
        new tmp[256], tmp2[256], index, id;
        tmp = strtok(params, index);
        tmp2 = strtok(params, index);

        if(!strlen(tmp))
        {
            SendClientMessage(playerid, 0xFF1212FF , "[KICK] Modo de utilizaзгo: /kick [ID] [Razгo]");
        }
        else if(!strlen(tmp2))
        {
            SendClientMessage(playerid, 0xFF1212FF , "[KICK] Modo de utilizaзгo: /kick [ID] [Razгo]");
        }
        else
        {
            id = strval(tmp);
            if(!IsPlayerConnected(id))
            {
                SendClientMessage(playerid, 0xFF1212FF , "[KICK] Esse Player nгo estб conectado");
            }
            else if(id == playerid)
            {
                SendClientMessage(playerid, 0xFF1212FF , "[KICK] Vocк nгo pode se kickar");
            }
            else if(gPlayerInfo[id][PLAYER_LEVEL] > gPlayerInfo[playerid][PLAYER_LEVEL])
            {
                SendClientMessage(playerid, 0xFF1212FF , "[KICK] Esse player tem um nнvel maior que o seu.");
            }
            else
            {
                new string[256], name[MAX_PLAYER_NAME];
                GetPlayerName(id, name, sizeof(name));
                if(id >= 0 && id <= 9)
                {
                    format(string, sizeof(string), "[KICK] Vocк foi kickado. Razгo: %s.", params[2]);
                    SendClientMessage(id, 0xFF1212FF , string);
                    Kick(id);
                    format(string, sizeof(string), "[KICK] O player %s foi kickado. Razгo: %s.", name, params[2]);
                    SendClientMessageToAll(0xFF1212FF , string);
                }
                else if(id >= 10 && id <= 99)
                {
                    format(string, sizeof(string), "[[KICK] Vocк foi kickado. Razгo: %s.", params[3]);
                    SendClientMessage(id, 0xFF1212FF , string);
                    Kick(id);
                    format(string, sizeof(string), "[KICK] O player %s foi kickado. Razгo: %s.", name, params[3]);
                    SendClientMessageToAll(0xFF1212FF , string);
                }
            }
        }
    }
    return 1;
}
dcmd_ban(playerid, params[])
{
    if(gPlayerInfo[playerid][PLAYER_LEVEL] < gCommands[KICK])
    {
        new string[128];
        format(string, sizeof(string), "Vocк Precisa ser %d de ADM para usar este comando!", gCommands[KICK]);
        SendClientMessage(playerid, 0xFF1212FF , string);
    }
    else
    {
        new tmp[256], tmp2[256], index, id;
        tmp = strtok(params, index);
        tmp2 = strtok(params, index);

        if(!strlen(tmp))
        {
            SendClientMessage(playerid, 0xFF1212FF , "[BAN] Modo de utilizaзгo: /ban [ID] [Razгo]");
        }
        else if(!strlen(tmp2))
        {
            SendClientMessage(playerid, 0xFF1212FF , "[BAN] Modo de utilizaзгo: /ban [ID] [Razгo]");
        }
        else
        {
            id = strval(tmp);
            if(!IsPlayerConnected(id))
            {
                SendClientMessage(playerid, 0xFF1212FF , "[BAN] Esse Player nгo estб conectado");
            }
            else if(id == playerid)
            {
                SendClientMessage(playerid, 0xFF1212FF , "[BAN] Vocк nгo pode banir vocк mesmo.");
            }
            else if(gPlayerInfo[id][PLAYER_LEVEL] > gPlayerInfo[playerid][PLAYER_LEVEL])
            {
                SendClientMessage(playerid, 0xFF1212FF , "[BAN] Este player tem um nнvel maior que o seu.");
            }
            else
            {
                new string[256], name[MAX_PLAYER_NAME];
                GetPlayerName(id, name, sizeof(name));
                if(id >= 0 && id <= 9)
                {
                    format(string, sizeof(string), "[BAN] Vocк foi banido. Razгo: %s.", params[2]);
                    SendClientMessage(id, 0xFF1212FF , string);
                    Kick(id);
                    format(string, sizeof(string), "[BAN] O Player %s foi banido. Razгo: %s.", name, params[2]);
                    SendClientMessageToAll(0xFF1212FF , string);
                }
                else if(id >= 10 && id <= 99)
                {
                    format(string, sizeof(string), "[BAN] Vocк foi banido. Razгo: %s.", params[3]);
                    SendClientMessage(id, 0xFF1212FF , string);
                    Kick(id);
                    format(string, sizeof(string), "[BAN] O Player %s foi banido. Razгo: %s.", name, params[3]);
                    SendClientMessageToAll(0xFF1212FF , string);
                }
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)