An urgent appeal.
#1

I use sscanf and ZCMD. I would like somebody to help me write an admin system. You can post it here for all to use, but I need it urgently. I basically want;

5 admin levels and I want to be able to make somebody admin with a /setadmin <ID> <adminlevel> command like that. I can do the rest of the admin commands myself.

Thank you so much. I've searched around but they're all in gibberish to me.
Reply
#2

Do you already have an account system? Or... is that what you need as part of the admin system?
Reply
#3

Yeah that'd be great. I literally have a very simple dialog system that seems to be a bit bugged. As when I log in, I need to click dialog arrows a few times then click SPAWN before I spawn. Im new to scripting, but I'm getting there.

I just really want the system and would appreciate you a tonne.
Reply
#4

I believe that's a simple fix, actually.

You probably aren't returning 1 under OnPlayerRequestClass. Otherwise, you didn't add a class to the GM and you'll need to add AT LEAST ONE with AddPlayerClass under OnGameModeInit().

You might actually want to use this as a base GM, if you didn't code a bunch already. I can send you a /setadmin command that works with that GM, too, if you want.

https://sampforum.blast.hk/showthread.php?tid=418944
Reply
#5

I just pasted that base GM in the file and got these warnings.

Код:
C:\Users\[0.3x]Test Server(HasCmds)\gamemodes\practiseADMINSYSTEM.pwn(212) : warning 235: public function lacks forward declaration (symbol "OnPlayerEnterDynamicCP")
C:\Users\[0.3x]Test Server(HasCmds)\gamemodes\practiseADMINSYSTEM.pwn(217) : warning 235: public function lacks forward declaration (symbol "OnPlayerLeaveDynamicCP")
C:\Users\[0.3x]Test Server(HasCmds)\gamemodes\practiseADMINSYSTEM.pwn(222) : warning 235: public function lacks forward declaration (symbol "OnPlayerEnterDynamicRaceCP")
C:\Users\[0.3x]Test Server(HasCmds)\gamemodes\practiseADMINSYSTEM.pwn(227) : warning 235: public function lacks forward declaration (symbol "OnPlayerLeaveDynamicRaceCP")
C:\Users\[0.3x]Test Server(HasCmds)\gamemodes\practiseADMINSYSTEM.pwn(252) : warning 235: public function lacks forward declaration (symbol "OnPlayerPickUpDynamicPickup")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase
Reply
#6

Also, I'll fiddle around with that base GM of course. Can you give me the setadmin stuff? The script I had was only 1000 lines or so and mostly commands, which I can import.

Can you send me that admin system please?
Reply
#7

Ah right, I forgot about those errors!

pawn Код:
// BoF - Beginning of File

#include <a_samp>
#include <a_mysql>
#include <sscanf2>
#include <foreach>
#include <zcmd>
#include <YSI\y_timers>
#include <streamer>

native WP_Hash(buffer[], len, const str[]); // Whirlpool is not an include, it is a plugin. This is all we need in order to use it in the script!

#define COLOR_RED           0xE7000000
#define COLOR_GREEN         0x80FF00B9
#define COLOR_WHITE         0xFFFFFFFF
#define COLOR_ORANGE        0xFF800000
#define COLOR_YELLOW        0xFFFF09C8
#define COLOR_LIGHTBLUE     0x379BFFC8
#define COLOR_LIGHTRED      0xFF6464C8
#define COLOR_GREY          0xC0C0C0C8

#define COLOR_DGREY1        0xE6E6E6E6
#define COLOR_DGREY2        0xC8C8C8C8
#define COLOR_DGREY3        0xAAAAAAAA
#define COLOR_DGREY4        0x8C8C8C8C
#define COLOR_DGREY5        0x6E6E6E6E

#define COL_EMB_RED         "{E70000}"
#define COL_EMB_GREEN       "{80FF00}"
#define COL_EMB_WHITE       "{FFFFFF}"
#define COL_EMB_ORANGE      "{FF8000}"
#define COL_EMB_YELLOW      "{FFFF09}"
#define COL_EMB_LIGHTBLUE   "{379BFF}"
#define COL_EMB_LIGHTRED    "{FF6464}"
#define COL_EMB_GREY        "{C0C0C0}"

new
    g_szFormatString[128]; // this global string is necessary for the defines below

#define fSendClientMessage(%1,%2,%3) \
    SendClientMessage(%1, %2, (format(g_szFormatString, sizeof(g_szFormatString), %3), g_szFormatString)) // you can use this define to prevent having to format a string inline; you can do it in a single function now
   
#define fSendClientMessageToAll(%1,%2) \
    sendGlobalMessage(%1, (format(g_szFormatString, sizeof(g_szFormatString), %2), g_szFormatString)) // you can use this define to prevent having to format a string inline; you can do it in a single function now

#define fSendAdminMessage(%1,%2) \
    sendAdminMessage(%1, (format(g_szFormatString, sizeof(g_szFormatString), %2), g_szFormatString)) // you can use this define to prevent having to format a string inline; you can do it in a single function now
   
#define fSendAreaMessage(%1,%2,%3,%4,%5,%6,%7) \
    sendAreaMessage(%1, %2, %3, %4, %5, %6, (format(g_szFormatString, sizeof(g_szFormatString), %7), g_szFormatString)) // you can use this define to prevent having to format a string inline; you can do it in a single function now
 
// -------------------- Server Definitions -------------------- //

    #define SCRIPT_VERSION "rev. 0.0.1"

    #define DEFAULT_CASH 1000 // set this to the amount of money player's should start with
    #define DEFAULT_LEVEL 1 // set this to the score/level player's should start with

   
        #define SQL_DEBUG 1 // enable MySQL debugging by keeping this as "1"; otherwise, use "0"
        #define connectionHandle 1 // change this only if you absolutely have to
       
        #define SQL_HOST ""
        #define SQL_USER ""
        #define SQL_DATA ""
        #define SQL_PASS ""
       
// ------------------------------------------------------------ //

enum // this is easier than handling a bunch of "#define" lines; you can just put a new line in the enum to make a new dialog definition
{
    DIALOG_REGISTER,
    DIALOG_SETGENDER,
    DIALOG_SETAGE,
    DIALOG_AUTHENTICATION
}

enum PLAYER_VARIABLES
{
    pDataID, // we use database ID's (data ID) as it's easier to handle than a username and provides easy table linking
    pPassword[129], // passwords are hashed, the hash is 128 + 1 for the null terminator, equaling 129
    pAdmin,
    pCash,
    pSavings,
    pBankAccount,
    pLevel,
    pKills,
    pDeaths,
    pRegTime, // registration time/date; saved as a timestamp
    pLastOn, // last time/date online; saved as a timestamp
    Float:pHealth,
    Float:pArmour,
    Float:pLastX, // on the last disconnect, this was the X position of the player
    Float:pLastY, // on the last disconnect, this was the Y position of the player
    Float:pLastZ, // on the last disconnect, this was the Z position of the player
    pSkin,
    pGender[7],
    pAge
};

new pInfo[MAX_PLAYERS][PLAYER_VARIABLES]; // this allows usage of the "pInfo" variable with the "PLAYER_VARIABLES" enumerator  

// -------------------- Global Player Variables -------------------- //

new // begins global bool vars
    bool:tAuthenticated[MAX_PLAYERS] = false
;
   
new // begins numerical global vars
    iLoginAttempts[MAX_PLAYERS] = 0
;

// ----------------------------------------------------------------- //

main(){}

public OnGameModeInit()
{
    mysql_debug(SQL_DEBUG);
    mysql_connect(SQL_HOST, SQL_USER, SQL_DATA, SQL_PASS);

    SetGameModeText(SCRIPT_VERSION);
    return 1;
}

public OnGameModeExit()
{
    mysql_close();
    return 1;
}

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

public OnPlayerConnect(playerid)
{
    if(!IsRolePlayName(playerid))
    {
        SendClientMessage(playerid, COLOR_WHITE, "Unfortunately, your name is not in the proper format! Please use the format of "#COL_EMB_LIGHTBLUE"\"Firstname_Lastname\""#COL_EMB_WHITE".");
        defer delayedKick(playerid);
    }
   
    TogglePlayerSpectating(playerid, true);
   
    new szQuery[500];
    format(szQuery, sizeof(szQuery), "SELECT * FROM `Bans` WHERE `Username` = '%s'", getEscName(playerid));
    mysql_function_query(connectionHandle, szQuery, true, "thread_checkBans", "d", playerid);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    saveVariables(playerid);
   
    new
        Float:fPos[3]
    ;
   
    GetPlayerPos(playerid, fPos[0], fPos[1], fPos[2])
    foreach(new i : Player)
        if(IsPlayerInRangeOfPoint(i, 7.0, fPos[0], fPos[1], fPos[2])) fSendClientMessage(i, COLOR_YELLOW, "* %s has disconnected from the server.", getName(playerid));
   
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    if(strlen(text) > 2)
        fSendAreaMessage(playerid, COLOR_DGREY1, COLOR_DGREY1, COLOR_DGREY2, COLOR_DGREY3, COLOR_DGREY4, "%s says: %s", getRolePlayName(playerid), text);
       
    return 0;
}

CMD:setadmin(playerid, params[])
{
    new
        iID,
        iLevel
    ;
   
    if(pInfo[playerid][pAdmin] < 5)
        return 1;
    if(sscanf(params, "ud", iID, iLevel))
        return SendClientMessage(playerid, COLOR_WHITE, "SYNTAX: /setadmin [nick/id] [level]"), 1;
    if(iID == INVALID_PLAYER_ID)
        return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid nickname/ID specified!"), 1;
    if(iLevel > 5)
        return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid level specified!"), 1;
       
    pInfo[iID][pAdmin] = iLevel;
   
    fSendClientMessage(playerid, COLOR_WHITE, "You have set %s(%d)'s admin level to: %d", getName(iID), iID, iLevel);
    fSendClientMessage(iID, COLOR_GREEN, "ADMIN: %s(%d) has set your admin level to: %d", getName(playerid), playerid, iLevel);
    return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterDynamicCP(playerid)
{
    return 1;
}

public OnPlayerLeaveDynamicCP(playerid)
{
    return 1;
}

public OnPlayerEnterDynamicRaceCP(playerid)
{
    return 1;
}

public OnPlayerLeaveDynamicRaceCP(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case DIALOG_REGISTER:
        {
            if(!response || isnull(inputtext))
                return clearPlayerChat(playerid), Kick(playerid);
            if(strlen(inputtext) < 4 || strlen(inputtext) > 50)
                return SendClientMessage(playerid, COLOR_RED, "ERROR: Your password cannot be shorter than 4 characters, or more than 50 characters."), SPD(playerid, DIALOG_REGISTER);
           
            new
                szBuffer[129];
               
            WP_Hash(szBuffer, sizeof(szBuffer), inputtext);        
            pInfo[playerid][pPassword] = szBuffer;
           
            SendClientMessage(playerid, COLOR_WHITE, "Okay, now let's set up your character.");
            SPD(playerid, DIALOG_SETGENDER);
        }
        case DIALOG_SETGENDER:
        {
            if(!response)
            {
                format(pInfo[playerid][pGender], 7, "female");
                SendClientMessage(playerid, COLOR_WHITE, "You have selected female.");
            }
            else
            {
                format(pInfo[playerid][pGender], 7, "male");
                SendClientMessage(playerid, COLOR_WHITE, "You have selected male.");
            }
           
            SPD(playerid, DIALOG_SETAGE);
        }
        case DIALOG_SETAGE:
        {
            if(!response)
            {
                clearPlayerChat(playerid);
                SendClientMessage(playerid, COLOR_RED, "You failed to complete the registration process. Goodbye.");
                Kick(playerid);
            }
           
            new iTemp = strval(inputtext);
            if(iTemp < 10 || iTemp > 80)
                return SendClientMessage(playerid, COLOR_RED, "Character ages cannot be less than 10, or greater than 80."), SPD(playerid, DIALOG_SETAGE);
           
            pInfo[playerid][pAge] = iTemp;
           
            new
                szQuery[300];
           
            format(szQuery, sizeof(szQuery), "INSERT INTO `Accounts` (`Username`, `Password`, `Level`, `Cash`, `RegTime`, `Gender`, `Age`) VALUES('%s', '%s', %d, %d, %d, '%s', %d)", getEscName(playerid), pInfo[playerid][pPassword], DEFAULT_LEVEL, DEFAULT_CASH, gettime(), pInfo[playerid][pGender], pInfo[playerid][pAge]);
            mysql_function_query(connectionHandle, szQuery, false, "thread_defaultCallback", "");
           
            clearPlayerChat(playerid);
            fSendClientMessage(playerid, COLOR_WHITE, "You have set your character's age to %d.", iTemp);
            SendClientMessage(playerid, -1, "");
            SendClientMessage(playerid, COLOR_WHITE, "You have completed the registration process! You will spawn momentarily...");
            TogglePlayerSpectating(playerid, false);
            tAuthenticated[playerid] = true;
           
            SetSpawnInfo(playerid, -1, 120, 131.5488, -69.1912, 1.5781, 0.0, 0, 0, 0, 0, 0, 0); // change 131.5488, -69.1912, 1.5781 to your desired spawn point X Y Z coordinates
            SpawnPlayer(playerid);
           
            pInfo[playerid][pCash] = DEFAULT_CASH;
            pInfo[playerid][pLevel] = DEFAULT_LEVEL;
           
            real_GivePlayerCash(playerid, DEFAULT_CASH);
            SetPlayerScore(playerid, pInfo[playerid][pLevel]);
        }
        case DIALOG_AUTHENTICATION:
        {
            if(!response || isnull(inputtext))
                return clearPlayerChat(playerid), Kick(playerid);
           
            new
                szBuffer[129];
           
            WP_Hash(szBuffer, sizeof(szBuffer), inputtext);
            if(!strcmp(szBuffer, pInfo[playerid][pPassword], false))
            {
                clearPlayerChat(playerid);
                fSendClientMessage(playerid, COLOR_WHITE, "Welcome back, "#COL_EMB_LIGHTBLUE"%s"#COL_EMB_WHITE"! Last online: "#COL_EMB_ORANGE"%s", getRolePlayName(playerid), date(pInfo[playerid][pLastOn], 2));
                TogglePlayerSpectating(playerid, false);
                tAuthenticated[playerid] = true;
           
                SetSpawnInfo(playerid, -1, pInfo[playerid][pSkin], pInfo[playerid][pLastX], pInfo[playerid][pLastY], pInfo[playerid][pLastZ], 0.0, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
            }
            else
            {
                iLoginAttempts[playerid]++;
                if(iLoginAttempts[playerid] > 3)
                {
                    iLoginAttempts[playerid] = 0;
                   
                    clearPlayerChat(playerid);
                    SendClientMessage(playerid, COLOR_RED, "You have failed to provide the password three times. Goodbye!");
                    Kick(playerid);
                }
                else SendClientMessage(playerid, COLOR_RED, "Incorrect password! Please try again..."), SPD(playerid, DIALOG_AUTHENTICATION);
            }
        }  
    }
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}

// ----- Threaded Callbacks [go below this line] ----- //

forward thread_checkBans(playerid);
public thread_checkBans(playerid)
{
    new
        szUsername[MAX_PLAYER_NAME],
        szAdminName[MAX_PLAYER_NAME],
        szReason[60],
        temp[30];
   
    cache_get_row(0, 0, temp);
    new iBanID = strval(temp);
    cache_get_row(0, 1, szUsername);
    cache_get_row(0, 2, szAdminName);
    cache_get_row(0, 3, szReason);
    cache_get_row(0, 4, temp);
    new iBannedTimestamp = strval(temp);
    cache_get_row(0, 5, temp);
    new iUnbannedTimestamp = strval(temp);
    cache_get_row(0, 6, temp);
    new iPerm = strval(temp);

    if(gettime() >= iUnbannedTimestamp)
    {
        new szQuery[128];
        format(szQuery, sizeof(szQuery), "DELETE FROM `Bans` WHERE `banID` = %d", iBanID);
        mysql_function_query(connectionHandle, szQuery, false, "thread_defaultCallback", "");
       
        format(szQuery, sizeof(szQuery), "SELECT * FROM `Accounts` WHERE `Username` = '%s'", getEscName(playerid));
        mysql_function_query(connectionHandle, szQuery, true, "thread_loadVariables", "d", playerid);
    }
    else
    {
        clearPlayerChat(playerid);

        SendClientMessage(playerid, COLOR_RED, "You are banned from this server.");
        SendClientMessage(playerid, -1, " ");
        fSendClientMessage(playerid, COLOR_WHITE, "You were banned by {E70000}%s {FFFFFF}on %s.", szAdminName, date(iBannedTimestamp, 2));
        fSendClientMessage(playerid, COLOR_WHITE, "Reason: %s", szReason);
        SendClientMessage(playerid, -1, " ");
        if(iPerm == 0) fSendClientMessage(playerid, COLOR_WHITE, "You will be automatically unbanned on %s.", date(iUnbannedTimestamp, 2));
        else if(iPerm == 1) SendClientMessage(playerid, COLOR_WHITE, "This is a permanent ban and it will not expire.");
        Kick(playerid);
    }  
    return 1;
}

forward thread_loadVariables(playerid);
public thread_loadVariables(playerid)
{
    new
        rows,
        fields;
       
    cache_get_data(rows, fields);
    if(rows == 1)
    {
        new temp[50];          
        cache_get_row(0, 0, temp);
        pInfo[playerid][pDataID] = strval(temp);
        cache_get_row(0, 2, pInfo[playerid][pPassword]);
        cache_get_row(0, 3, temp);
        pInfo[playerid][pAdmin] = strval(temp);
        cache_get_row(0, 4, temp);
        pInfo[playerid][pCash] = strval(temp);
        cache_get_row(0, 5, temp);
        pInfo[playerid][pSavings] = strval(temp);
        cache_get_row(0, 6, temp);
        pInfo[playerid][pBankAccount] = strval(temp);
        cache_get_row(0, 7, temp);
        pInfo[playerid][pLevel] = strval(temp);
        cache_get_row(0, 8, temp);
        pInfo[playerid][pKills] = strval(temp);
        cache_get_row(0, 9, temp);
        pInfo[playerid][pDeaths] = strval(temp);
        cache_get_row(0, 10, temp);
        pInfo[playerid][pRegTime] = strval(temp);
        cache_get_row(0, 11, temp);
        pInfo[playerid][pLastOn] = strval(temp);
        cache_get_row(0, 13, temp);
        pInfo[playerid][pHealth] = floatstr(temp);
        cache_get_row(0, 14, temp);
        pInfo[playerid][pArmour] = floatstr(temp);
        cache_get_row(0, 15, temp);
        pInfo[playerid][pLastX] = floatstr(temp);
        cache_get_row(0, 16, temp);
        pInfo[playerid][pLastY] = floatstr(temp);
        cache_get_row(0, 17, temp);
        pInfo[playerid][pLastY] = floatstr(temp);
        cache_get_row(0, 18, temp);
        pInfo[playerid][pSkin] = strval(temp);
        cache_get_row(0, 19, pInfo[playerid][pGender]);
        cache_get_row(0, 20, temp);
        pInfo[playerid][pAge] = strval(temp);
       
        clearPlayerChat(playerid);
        SendClientMessage(playerid, COLOR_WHITE, "SERVER: This account "#COL_EMB_GREEN"has been registered."#COL_EMB_WHITE" Please authenticate in order to proceed.");
        SPD(playerid, DIALOG_AUTHENTICATION);
    }
    else if(rows == 0)
    {
        clearPlayerChat(playerid);
        SendClientMessage(playerid, COLOR_WHITE, "SERVER: This account has "#COL_EMB_RED"not been registered"#COL_EMB_WHITE".");
        SPD(playerid, DIALOG_REGISTER);
    }
    else
    {
        clearPlayerChat(playerid);
        SendClientMessage(playerid, COLOR_WHITE, "There was a "#COL_EMB_RED"fatal error "#COL_EMB_WHITE"during registration! Please contact a developer.");
        Kick(playerid);
    }
    return 1;
}

forward thread_defaultCallback(playerid);
public thread_defaultCallback(playerid)
{
    return 1;
}

// --------------- Timers [go below this line] -------------- //

timer delayedKick[500](playerid) Kick(playerid);

// ---------- Stock Functions [go below this line] ---------- //

stock saveVariables(playerid)
{
    if(tAuthenticated[playerid])
    {
        new
            szQuery[1000],
            Float:pFloatValue[5];
       
        GetPlayerHealth(playerid, pFloatValue[0]);
        GetPlayerArmour(playerid, pFloatValue[1]);
        GetPlayerPos(playerid, pFloatValue[2], pFloatValue[3], pFloatValue[4]);
           
        format(szQuery, sizeof(szQuery), "UPDATE `Accounts` SET `adminLevel` = %d, `Cash` = %d, `Savings` = %d, `BankAccount` = %d, `Level` = %d, `Kills` = %d, `Deaths` = %d, `LastOn` = %d, `Health` = %f, `Armour` = %f, `LastX` = %f, `LastY` = %f, `LastZ` = %f, `Gender` = '%s' AND `Age` = %d WHERE `Username` = '%s'",
            pInfo[playerid][pAdmin],
            real_GetPlayerCash(playerid),
            pInfo[playerid][pSavings],
            pInfo[playerid][pBankAccount],
            pInfo[playerid][pLevel],
            pInfo[playerid][pKills],
            pInfo[playerid][pDeaths],
            gettime(),
            pFloatValue[0],
            pFloatValue[1],
            pFloatValue[2],
            pFloatValue[3],
            pFloatValue[4],
            pInfo[playerid][pGender],
            pInfo[playerid][pAge],
            getEscName(playerid));
       
        mysql_function_query(connectionHandle, szQuery, false, "thread_defaultCallback", "");
    }
    return 1;
}

stock sendAreaMessage(playerid, color, color1, color2, color3, color4, string[])
{
    new
        Float:fPos[3]
    ;  
   
    GetPlayerPos(playerid, fPos[0], fPos[1], fPos[2])
    foreach(new i : Player)
    {
        if(IsPlayerInRangeOfPoint(i, 7.0, fPos[0], fPos[1], fPos[2])) SendClientMessage(i, color, string);
        else if(IsPlayerInRangeOfPoint(i, 10.0, fPos[0], fPos[1], fPos[2])) SendClientMessage(i, color1, string);
        else if(IsPlayerInRangeOfPoint(i, 15.0, fPos[0], fPos[1], fPos[2])) SendClientMessage(i, color2, string);
        else if(IsPlayerInRangeOfPoint(i, 20.0, fPos[0], fPos[1], fPos[2])) SendClientMessage(i, color3, string);
        else if(IsPlayerInRangeOfPoint(i, 25.0, fPos[0], fPos[1], fPos[2])) SendClientMessage(i, color4, string);
    }
}
       
stock SPD(playerid, dialogid) // a shortened custom function for ShowPlayerDialog; you don't have to handle all of the ShowPlayerDialog lines, just know the playerid and the dialogid you want to show
{
    switch(dialogid)
    {
        case DIALOG_REGISTER: ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""#COL_EMB_WHITE"Account Registration", ""#COL_EMB_WHITE"This account has "#COL_EMB_RED"not been registered"#COL_EMB_WHITE"!\n\nEnter your desired password below to register this account.", "Submit", "Leave");
        case DIALOG_AUTHENTICATION: ShowPlayerDialog(playerid, DIALOG_AUTHENTICATION, DIALOG_STYLE_PASSWORD, ""#COL_EMB_WHITE"Account Authentication", ""#COL_EMB_WHITE"This account has "#COL_EMB_GREEN"been registered"#COL_EMB_WHITE"!\n\nEnter the account password below to proceed.", "Submit", "Leave");
        case DIALOG_SETGENDER: ShowPlayerDialog(playerid, DIALOG_SETGENDER, DIALOG_STYLE_MSGBOX, ""#COL_EMB_WHITE"Gender Selection", ""#COL_EMB_WHITE"What is your character's gender?", "Male", "Female");
        case DIALOG_SETAGE: ShowPlayerDialog(playerid, DIALOG_SETAGE, DIALOG_STYLE_INPUT, ""#COL_EMB_WHITE" Age Selection", ""#COL_EMB_WHITE"How old is your character going to be?\n\nValid ages are between between 10 and 80.", "Submit", "Leave");
    }
    return -1;
}

stock clearPlayerChat(playerid, lines = 20)
{
    for(new i; i < lines; i++) SendClientMessage(playerid, -1, " ");
    return -1;
}

stock getName(playerid)
{
    new
        szName[MAX_PLAYER_NAME];
   
    GetPlayerName(playerid, szName, sizeof(szName));
    return szName;
}

stock getRolePlayName(playerid)
{
    new
        szName[MAX_PLAYER_NAME],
        stringPos;
       
    GetPlayerName(playerid, szName, sizeof(szName));
    stringPos = strfind(szName, "_");
    szName[stringPos] = ' ';
    return szName;
}

stock getEscName(playerid)
{
    new szUsername[25], szEscName[26];
    GetPlayerName(playerid, szUsername, sizeof(szUsername));
    mysql_real_escape_string(szUsername, szEscName);
    return szEscName;
}

stock IsRolePlayName(playerid)
{
    new trpn[MAX_PLAYER_NAME];
    GetPlayerName(playerid, trpn, sizeof(trpn));
    new strd = strfind(trpn, "_", false);
    if(strfind(trpn,"_",false,strd+1) == -1)
    {
        if(strd > 0)
        {
            if(trpn[strd-1] && trpn[strd+1])
            {
                for(new a = 0, l = strlen(trpn); a < l; a++)
                {
                    switch(trpn[a])
                    {
                        case '0' .. '9': return 0;
                        case 'a' .. 'z': continue;
                        case 'A' .. 'Z': continue;
                        case '_': continue;
                        default: return 0;
                    }
                }
                return 1;
            }
        }
    }
    return 0;
}

stock returnTime()
{
    new hr, minute, sec;
    gettime(hr, minute, sec);

    new szString[30];
    format(szString, sizeof(szString), "%d:%d:%d", hr, minute, sec);
    return szString;
}

stock returnDate()
{
    new day, mon, year;
    gettime(year, mon, day);

    new szString[30];
    format(szString, sizeof(szString), "%d/%d/%d", mon, day, year);
    return szString;
}

stock date(timestamp, _form = 0) // credits to whoever made this function
{
    /*  date( 1247182451 )  will print >> 09.07.2009-23:34:11
        date( 1247182451, 1) will print >> 09/07/2009
        date( 1247182451, 2) will print >> July 09, 2009 at 23:34:11
        date( 1247182451, 3) will print >> 9 Jul 2009, 23:34
        date( 1247182451, 4) will print >> 23:34
    */

       
    new year=1970, day=0, month=0, hours=0, mins=0, sec=0;

    new days_of_month[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
    new names_of_month[12][10] = {"January","February","March","April","May","June","July","August","September","October","November","December"};
    new returnstring[32];

    while(timestamp>31622400)
    {
        timestamp -= 31536000;
        if ( ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0) ) timestamp -= 86400;
        year++;
    }

    if ( ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0) )
        days_of_month[1] = 29;
    else
        days_of_month[1] = 28;

    while(timestamp>86400)
    {
        timestamp -= 86400, day++;
        if(day==days_of_month[month]) day=0, month++;
    }
    while(timestamp>60)
    {
        timestamp -= 60, mins++;
        if( mins == 60) mins=0, hours++;
    }
    sec=timestamp;
    switch( _form )
    {
        case 1: format(returnstring, 31, "%02d/%02d/%d - %02d:%02d", day+1, month+1, year, hours, mins);
        case 2: format(returnstring, 31, "%s %02d, %d at %02d:%02d", names_of_month[month], day+1, year, hours, mins);
        case 3: format(returnstring, 31, "%d %c%c%c %d, %02d:%02d", day+1, names_of_month[month][0], names_of_month[month][1], names_of_month[month][2], year, hours, mins);
        case 4: format(returnstring, 31, "%02d:%02d:%02d", hours, mins, sec);
        default: format(returnstring, 31, "%02d.%02d.%d-%02d:%02d:%02d", day+1, month+1, year, hours, mins, sec);
    }

    return returnstring;
}

stock mktime(hour, minute, second, day, month, year) // credits to ******
{
    static days_of_month[12] =
    { 31,   29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
    lMinute, lHour, lDay, lMonth, lYear, lMinuteS, lHourS, lDayS, lMonthS, lYearS;
       
    if (year != lYear)
    {
        lYearS = 0;
        for (new j = 1970; j < year; j++)
        {
            lYearS += 31536000;
            if ((!(j % 4) && (j % 100)) || !(j % 400)) lYearS += 86400;
        }
        lYear = year;
    }
    if (month != lMonth)
    {
        lMonthS = 0;
        month--;
        for (new i = 0; i < month; i++)
        {
            lMonthS += days_of_month[i] * 86400;
            if ((i == 1) && ((!(year % 4) && (year % 100)) || !(year % 400))) lMonthS += 86400;
        }
        lMonth = month;
    }
    if (day != lDay)
    {
        lDayS = day * 86400;
        lDay = day;
    }
    if (hour != lHour)
    {
        lHourS = hour * 3600;
        lHour = hour;
    }
    if (minute != lMinute)
    {
        lMinuteS = minute * 60;
        lMinute = minute;
    }
    return lYearS + lMonthS + lDayS + lHourS + lMinuteS + second;
}

// ---------- Server-Side Money System [functions begin] ---------- //
   
stock real_GivePlayerCash(playerid, value)
{
    pInfo[playerid][pCash] += value;   
   
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid, pInfo[playerid][pCash]);
    return 1;
}
   
stock real_TakePlayerCash(playerid, value)
{
    pInfo[playerid][pCash] -= value;   
   
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid, pInfo[playerid][pCash]);
    return 1;
}

stock real_SetPlayerCash(playerid, value)
{
    pInfo[playerid][pCash] = value;
   
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid, value);
    return 1;
}

stock real_ResetPlayerCash(playerid)
{
    pInfo[playerid][pCash] = 0;    
    ResetPlayerMoney(playerid);
    return 1;
}

stock real_GetPlayerCash(playerid)
    return pInfo[playerid][pCash];
   
// ---------------------------------------------- //



// EoF - End of File
Reply
#8

Alright. So I decided that I'm gonna continue working on my one as I dont have MYSQL and I dont want to pay money or anything, I just want to get to grips with my server first which I have been doing for ages.

So, can you just send me a normal admin system with 5 admin levels?
Reply
#9

MySQL is free, just download WAMP or XAMPP.

Either way, I'll search for something and if I don't find anything, I'll make you something using y_ini (IIRC, the fastest file-based system other than native file functions).
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)