[Tutorial] [TUT] Creating a Register System using Dini
#41

Quote:
Originally Posted by dirkblok
Hey,

How can I make it save the money when the player disconnects?

Thanks
Add this under OnPlayerDisconnect:

Code:
dini_IntSet(file,"Cash", GetPlayerMoney(playerid));
Quote:
Originally Posted by Lajko1
fixed i just wanna ask you , how i can make when player chose skin in class selection like example : skin 50 it will save to script files , and when he go offline and later come back he will have same skin 50 when he login ? how to do this ? like in crazy bob server , i hope you can help , ty
Add "Skin" in the enum pInfo.

Under the /login cmd add:

Code:
SetPlayerSkin(playerid, dini_Int(file, "Skin"));
Add this under OnPlayerSpawn:

Code:
dini_IntSet(file,"Skin", GetPlayerSkin(playerid));
Reply
#42

Post at the script.request thread
Reply
#43

Where i add that
Code:
enum pInfo
{

}
new PlayerInfo[MAX_PLAYERS][pInfo];
?
Reply
#44

Quote:
Originally Posted by [03]Garsino
Посмотреть сообщение
Usefull for newbies like me!
ftw!!!!!
Reply
#45

Hy, this is very good tutorial...But i have one one warning.
Here he is:
Код:
C:\Users\SARMA\Desktop\Sarma's RolePlay\gamemodes\Sarma'sRolePlay.pwn(299) : warning 203: symbol is never used: "strtok"
Pls Help....

Sorry on my bad English..
Reply
#46

Quote:
Originally Posted by sorfa
Посмотреть сообщение
Hy, this is very good tutorial...But i have one one warning.
Here he is:
Код:
C:\Users\SARMA\Desktop\Sarma's RolePlay\gamemodes\Sarma'sRolePlay.pwn(299) : warning 203: symbol is never used: "strtok"
Pls Help....

Sorry on my bad English..
You can just ignore this lol. It just says that the symbol strtok isn't in use.
Reply
#47

Tnx...But i fix it...
Reply
#48

what is eadmin
Reply
#49

Quote:
Originally Posted by Anthony[Gl-RP]
View Post
what is eadmin
its a defined color in this tutorial
Reply
#50

Can someone post a script with this finished because I kept getting all these errors
Reply
#51

Here it had some erros but maneged to fix em as always....

If anyone had some errors just coppy this
pawn Code:
#include <a_samp>
#include <dini>
#include <dudb>
#define COLOR 0xFFFF00AA
#pragma unused ret_memcpy
#define eadmin 0x33660000


//------------------------
new IsLogged[MAX_PLAYERS];

enum pInfo
{
    AdminLevel,
         Cash,
}

new PlayerInfo[MAX_PLAYERS][pInfo];

public OnPlayerDisconnect(playerid, reason)
{
IsLogged[playerid] = 0;
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256], idx, file[128], tmp[256], tmp2[256];
    cmd = strtok(cmdtext, idx);

    if(strcmp(cmd, "/register", true) == 0)
    {
        new name[MAX_PLAYER_NAME];
        tmp = strtok(cmdtext, idx);
        GetPlayerName(playerid, name, sizeof(name));
        if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /register [password]");
        format(file,sizeof(file),"%s.ini",name);
        if(!fexist(file))
            {
                dini_Create(file);
                dini_IntSet(file, "Password", udb_hash(tmp));
                dini_IntSet(file,"AdminLevel", 0);
                dini_IntSet(file,"Cash", 0);
                SendClientMessage(playerid, eadmin, "[System]: Account Created!");
                PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
                GetPlayerName(playerid, name, sizeof(name));
                printf("%s has registered a account!", name);
            }
            else
            {
                SendClientMessage(playerid, COLOR, " Account Already Found In Database");
                PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
            }
        return 1;
    }

    if(strcmp(cmd, "/login", true) == 0)
    {
        new PlayerName[24];
        tmp = strtok(cmdtext, idx);
        if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /login [password]");
        new name[MAX_PLAYER_NAME];
        if(IsLogged[playerid] == 1)
        {
            SendClientMessage(playerid, COLOR, "You already are logged in!");
            return 1;
        }
        else
        {
            GetPlayerName(playerid, name, sizeof(name));
            format(file,sizeof(file),"%s.ini",name);
            if(fexist(file))
            {
                tmp2 = dini_Get(file, "Password");
                if(udb_hash(tmp) != strval(tmp2))
                {
                    SendClientMessage(playerid, COLOR, "Login Failed!");
                    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
                    printf("%s has failed to login", name);
                }
                else
                {
                    IsLogged[playerid] = 1;
                    SetPlayerMoney(playerid, dini_Int(file, "Cash"));
                    PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
                    SendClientMessage(playerid, COLOR, "[System]: Account Logged into!");
                }
            }
        }
        return 1;
        }
    return 0;
    }
Reply
#52

So for what is these variables in the code, what they doing?
Code:
new cmd[256], idx, file[128], tmp[256], tmp2[256];
cmd = strtok(cmdtext, idx);
Reply
#53

if(gLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR, "SERVER: You have not logged in yet.");
Kick(playerid);
return 1;
}

Where does this go?
Reply
#54

Quote:
Originally Posted by Rabbayazza
View Post
if(gLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR, "SERVER: You have not logged in yet.");
Kick(playerid);
return 1;
}

Where does this go?
Did you really bring this thread back to life? It was dead last year, and so was dini.
Reply
#55

Well as you can probably see from my post count, I don't know anything about scripting, so tell me where it goes please.
Reply
#56

This helped me alot!! Thanks

Oh, i hate this lol
This forum requires that you wait 120 seconds between posts. Please try again in 100 seconds.
Reply
#57

Quote:

C:\gamemodes\1stDM.pwn(701) : error 017: undefined symbol "tmp"
C:\gamemodes\1stDM.pwn(701) : error 017: undefined symbol "cmdtext"
C:\gamemodes\1stDM.pwn(703) : error 017: undefined symbol "tmp"
C:\gamemodes\1stDM.pwn(704) : error 017: undefined symbol "file"
C:\gamemodes\1stDM.pwn(704) : error 017: undefined symbol "file"

I just converted the commands to ZCMD >.<...god dammit, lol.
Reply
#58

Quote:
Originally Posted by Darnell
View Post
I just converted the commands to ZCMD >.<...god dammit, lol.
I suggest using Y_INI. This is an outdated tutorial.

Also, You should use SSCANF.
Reply
#59

Uhm, so, dini_Int is INI_Int if I'm going to use Y_Ini, for example ?
Reply
#60

i get this error:
Code:
error 017: undefined symbol "file"
what should i do?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)