SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 04/08/2015, 11:13 PM   #1
Lajko1
High-roller
 
Join Date: Oct 2008
Posts: 1,235
Reputation: 17
Default Ways of saving (yini)

I'm wondering if there's any better and more proper way of saving up to 15 player's crimes (for RP server)
What I did is this:

pawn Code:
enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths,
    pCrime0,
    pCrimeReason0[128],
    pCrime1,
    pCrimeReason1[128],
    pCrime2,
    pCrimeReason2[128]
    // All way to 15 crimes
}
new PlayerInfo[MAX_PLAYERS][pInfo];

pawn Code:
CMD:suspect(playerid,params[])
{
    new id, crime[128], string[128];
    if(sscanf(params, "us[80]",id ,crime)) return SendClientMessage(playerid,-1,"USAGE: /suspect [PlayerID/Part of Name] [Crime]");
    if(PlayerInfo[id][pCrime0] == 0)
    {
        format(string, sizeof(string), "Your crime is: %s", crime);
        SendClientMessage(playerid, -1, string);
        PlayerInfo[id][pCrime0] = 1;
        PlayerInfo[id][pCrimeReason0] = crime;
    }
    else if(PlayerInfo[id][pCrime1] == 0)
    {
        format(string, sizeof(string), "Your crime is: %s", crime);
        SendClientMessage(playerid, -1, string);
        PlayerInfo[id][pCrime1] = 1;
        PlayerInfo[id][pCrimeReason1] = crime;
    }
    else
    {
        format(string, sizeof(string), "Your crime is: %s", crime);
        SendClientMessage(playerid, -1, string);
        PlayerInfo[id][pCrime2] = 1;
        PlayerInfo[id][pCrimeReason2] = crime;
    }
    return 1;
}
Lajko1 is offline   Reply With Quote
Old 04/08/2015, 11:33 PM   #2
Zonoya
Gangsta
 
Zonoya's Avatar
 
Join Date: Jul 2011
Location: Am I in Rio de Janeiro or the Amazon, you tell me?
Posts: 664
Reputation: 19
Default Re: Ways of saving (yini)

Arrays, perhaps?

Like, instead of:

pCrime0 all the way to fifteen, have

Code:
pCrime[15],
pCrimeReasons[15][128],
Or something like that? You'd still have to save it all separately, though, I don't use Y_INI much for saving, so, couldn't help there.
__________________
Code:
public OnRconLoginAttempt(ip[], password[], success)
{
    if(!success) //If the password was incorrect
    {
        printf("FAILED RCON LOGIN BY IP %s USING PASSWORD %s",ip, password);
        new pip[16];
        for(new i=0; i<MAX_PLAYERS; i++) //Loop through all players
        {
            GetPlayerIp(i, pip, sizeof(pip));
            if(!strcmp(ip, pip, true)) //If a player's IP is the IP that failed the login
            {
                SendClientMessage(i, 0xFFFFFFFF, "Wrong Password. Bye!"); //Send a message
                Ban(i); //They are now banned.
            }
        }
    }
    return 1;
}
Zonoya is offline   Reply With Quote
Old 04/08/2015, 11:36 PM   #3
Lajko1
High-roller
 
Join Date: Oct 2008
Posts: 1,235
Reputation: 17
Default Re: Ways of saving (yini)

Command remains in same way or is there any possibility of looping or whatever?
Lajko1 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
My YINI system is saving with no name. Kratory Scripting Help 4 28/06/2014 10:26 PM
Yini double saving Glad2BeHere Scripting Help 8 13/12/2012 05:23 PM
yini-not saving Glad2BeHere Scripting Help 0 29/11/2012 06:40 AM
YINI to MYSQL saving? marcoj Scripting Help 0 13/07/2012 07:31 PM
File Systems / Ways of saving data Giovanni Scripting Help 3 13/10/2011 08:12 PM


All times are GMT. The time now is 02:28 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.