Save Player Score HELP!!! I give repS+++
#1

How to make the server save Player's Score

PLEASE PLACE CODES IN MY SCRIPT.. HERE's MY GAMEMODE:

Код:
#include <a_samp>
#include <streamer>
#include <dudb>

#define COL_EASY           "{FFF1AF}"
#define COL_WHITE          "{FFFFFF}"
#define COL_BLACK          "{0E0101}"
#define COL_GREY           "{C3C3C3}"
#define COL_GREEN          "{6EF83C}"
#define COL_RED            "{F81414}"
#define COL_YELLOW         "{F3FF02}"
#define COL_ORANGE         "{FFAF00}"
#define COL_LIME           "{B7FF00}"
#define COL_CYAN           "{00FFEE}"
#define COL_LIGHTBLUE      "{00C0FF}"
#define COL_BLUE           "{0049FF}"
#define COL_MAGENTA        "{F300FF}"
#define COL_VIOLET         "{B700FF}"
#define COL_PINK           "{FF00EA}"
#define COL_MARONE         "{A90202}"
#define COL_CMD            "{B8FF02}"
#define COL_PARAM          "{3FCD02}"
#define COL_SERVER         "{AFE7FF}"
#define COL_VALUE 		   "{A3E4FF}"
#define COL_RULE  	   	   "{F9E8B7}"
#define COL_RULE2 		   "{FBDF89}"
#define COL_RWHITE 		   "{FFFFFF}"
#define COL_LGREEN         "{C9FFAB}"
#define COL_LRED           "{FFA1A1}"
#define COL_LRED2          "{C77D87}"

#define skin 120
new bool:IsDead[MAX_PLAYERS];
stock static const Float:aSpawns[][] =
{
    {1178.4154,-1323.6300,14.1190}  
};

new logged[MAX_PLAYERS];
new adminlevel[MAX_PLAYERS];
new money[MAX_PLAYERS];
new playername[MAX_PLAYER_NAME];

// forwards//
forward SetPlayerWorld(playerid);
forward SetPlayerWorldOpen(playerid);

main()
{
    print("===============================");
    print("");
    print("===============================");
}

public OnGameModeInit()
{
    SetGameModeText("Offline");
    ShowPlayerMarkers(PLAYER_MARKERS_MODE_STREAMED);
	EnableStuntBonusForAll(0);
	DisableInteriorEnterExits();
    //map icon//
    CreateDynamicMapIcon(-988.7530, -2327.2246, 65.5251, 38, -1, -1, -1, -1, 100); //Woodcreature
    return 1;
}

stock CreatePickupWith3DText(model, type, Float:X, Float:Y, Float:Z, Virtualworld, text[], color)
{
    CreatePickup(model, type, Float:X, Float:Y, Float:Z, Virtualworld);
    Create3DTextLabel(text[], color, Float:X, Float:Y, Float:Z+0.75, 0, Virtualworld, 1);
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    new pname[MAX_PLAYER_NAME], string[22 + MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(string, sizeof(string), "%s has joined the server", pname);
    SendClientMessageToAll(0xAAAAAAAA, string);
    SendDeathMessage(INVALID_PLAYER_ID,playerid, 200);
    SetPlayerVirtualWorld(playerid,playerid+1);
    logged[playerid] = 0;
    ShowPlayerDialog(playerid, skin, DIALOG_STYLE_INPUT, "Skin Select", "Enter a skin ID below to get started", "Confirm", "Cancel");
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    money[playerid] = GetPlayerMoney(playerid);
    dini_IntSet(udb_encode(playername), "money", money[playerid]);
    dini_IntSet(udb_encode(playername), "adminlevel", adminlevel[playerid]);
    dini_IntSet(udb_encode(playername), "level", GetPlayerScore(playerid));
    logged[playerid] = 0;
    new pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    switch(reason)
    {
        case 0: format(string, sizeof(string), "%s has left the server. (Lost Connection)", pname);
        case 1: format(string, sizeof(string), "%s has left the server. (Leaving)", pname);
        case 2: format(string, sizeof(string), "%s has left the server. (Kicked)", pname);
    }
    SendClientMessageToAll(0xAAAAAAAA, string);
    SendDeathMessage(INVALID_PLAYER_ID,playerid, 201);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256],tmp[256], tmp2[256];
    new idx;
    new string[256];
    cmd = strtok(cmdtext, idx);
    GetPlayerName(playerid, playername, sizeof(playername));
    if(strcmp(cmd, "/register", true) == 0)
    {
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, -1, "USAGE: /register (password)");
        }
        else
        {
            if (!dini_Exists(udb_encode(playername)))
            {
                dini_Create(udb_encode(playername));
                dini_IntSet(udb_encode(playername), "password", udb_hash(tmp));
                dini_IntSet(udb_encode(playername), "adminlevel", 0);
                dini_IntSet(udb_encode(playername), "money", 0);
                format(string, sizeof(string), ""COL_GREEN"[ACCOUNT]: "COL_YELLOW" Account '%s' created! "COL_WHITE"You can now login with /login ( existing password )", playername, tmp);
                GivePlayerMoney(playerid, 999999);
                SendClientMessage(playerid, -1, string);
            }
            else
            {
                format(string, sizeof(string), "This %s account is already registered !", playername,tmp);
                SendClientMessage(playerid, -1, string);
            }
        }
        return 1;
    }


    if(strcmp(cmd, "/login", true) == 0)
    {
        if(logged[playerid] == 1)
        {
            SendClientMessage(playerid, -1, ""COL_GREEN"[ACCOUNT]: "COL_ORANGE"You are already logged in !");
            return 1;
        }
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, -1, "[USAGE]: /login ( password )");
        }
        else
        {
            if (dini_Exists(udb_encode(playername)))
            {
                tmp2 = dini_Get(udb_encode(playername), "password");
                if (udb_hash(tmp) != strval(tmp2))
                {
                    SendClientMessage(playerid, -1, ""COL_GREEN""COL_RED"[ACCOUNT]: "COL_ORANGE"Password not match !");
                }
                else
                {
                    logged[playerid] = 1;
                    money[playerid] = dini_Int(udb_encode(playername), "money");
                    adminlevel[playerid] = dini_Int(udb_encode(playername), "adminlevel");
                    format(string, sizeof(string), ""COL_YELLOW"[ACCOUNT] "COL_GREEN"you are now logged in . "COL_WHITE"You got admin level "COL_GREEN"%d {FFFFFF}and have "COL_GREEN"%d {FFFFFF}dollar!", adminlevel[playerid], money[playerid]);
                    SendClientMessage(playerid, -1, string);
                    GivePlayerMoney(playerid, money[playerid]);
                    SetTimerEx("SetPlayerWorld", 1000, false, "i", playerid);
                }
            }
            else
            {
                format(string, sizeof(string), ""COL_RED"[ACCOUNT]:{FFFFFF}The username are not registered yet ! "COL_YELLOW"Type /register ( password ) to create an account !", playername);
                SendClientMessage(playerid, -1, string);
            }
        }
        return 1;
    }

    if(strcmp(cmd, "/makemeadmin", true) == 0)
    {
        if(IsPlayerAdmin(playerid))
        {
            if(logged[playerid] == 1)
            {
                if(adminlevel[playerid] != 3)
                {
                    adminlevel[playerid] = 5;
                    SendClientMessage(playerid, -1, ""COL_GREEN"[ACCOUNT]: "COL_YELLOW"You are now maxlevel admin!");
                }
                else
                {
                    SendClientMessage(playerid, -1, ""COL_GREEN"[ACCOUNT]: "COL_ORANGE"You are already maxlevel admin!");
                }
            }
            else
            {
                SendClientMessage(playerid, -1, ""COL_GREEN"[ACCOUNT]: {FFFFFF}Please, first login: /login [password]");
            }
        }
        else
        {
            SendClientMessage(playerid, -1, ""COL_GREEN"[ACCOUNT]: "COL_ORANGE"You must first login with rcon ! {FFFFFF}(/rcon login ( rcon-pass )");
        }
		return 1;
	}
	return 0;

}

public OnPlayerSpawn(playerid)
{
    if(logged[playerid] == 0)
    {
        SendClientMessage(playerid, -1, ""COL_ORANGE"[ACCOUNT]: {FFFFFF}You are not logged in yet. "COL_YELLOW"USAGE: Use /login (password)");
    }
    
    if(IsDead[playerid])
    {
        new rand = random(sizeof(aSpawns));
        SetPlayerPos(playerid, aSpawns[rand][0], aSpawns[rand][1], aSpawns[rand][2]);
        IsDead[playerid] = false;
        return 1;
    }
    
    return 1;
}
Reply
#2

For that you need to save it with y_ini or some othet source to save and load..
Reply
#3

Quote:
Originally Posted by fuckingcruse
Посмотреть сообщение
For that you need to save it with y_ini or some othet source to save and load..
Is it possible with dudb?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)