SA-MP Forums Archive
storing data? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: storing data? (/showthread.php?tid=402361)



storing data? - NicholasA - 26.12.2012

Hey guys i was wondering on how i could do something like this:

When you type a command like /buybooboo
The server knows that you have bought a booboo and wont allow you to buy more booboo's.
Also there is a command /wearbooboo that you can only type when you have bought a booboo


Re: storing data? - DaRk_RaiN - 26.12.2012

Use a variable,this method is not insured in case the player disconnects, else use Y_INI to save them
pawn Code:
new bbooboo[MAX_PLAYERS];
new wbooboo[MAX_PLAYERS];
pawn Code:
if (strcmp("/buybooboo", cmdtext, true, 10) == 0)
    {
        // your script bla bla
        bbooboo[playerid] = 1;//now this will make you know if he bought
        return 1;
    }
    if (strcmp(" /wearbooboo", cmdtext, true, 10) == 0)
    {
        // your script bla bla
        wbooboo[playerid] = 1;//now this will make you know if he wears it.
        return 1;
    }
Now if you want him to only buy this bla bla once
pawn Code:
if (strcmp("/buybooboo", cmdtext, true, 10) == 0)
    {
        if(bbooboo[playerid] == 1)return SendClientMessage(playerid,-1,"Dude wtf you already bought one");//he won't be abl to buy an other one unless he uses this one
        // your script bla bla
        bbooboo[playerid] = 1;//now this will make you know if he bought
        return 1;
    }
Now when he wears that bla bla He'll have to buy an other one
pawn Code:
if (strcmp(" /wearbooboo", cmdtext, true, 10) == 0)
    {
        if(bbooboo[playerid] == 0)return SendClientMessage(playerid,-1,"You don't have a bbooboo to wear");//in case he doesn't have a blabla
        bbooboo[playerid] = 0;//this will make him lose a bla bla
        // your script bla bla
        wbooboo[playerid] = 1;//now this will make you know if he wears it.
        return 1;
    }
If your looking for an other way of using those tell me.


Re: storing data? - NicholasA - 27.12.2012

Quote:
Originally Posted by DaRk_RaiN
View Post
Use a variable,this method is not insured in case the player disconnects, else use Y_INI to save them
pawn Code:
new bbooboo[MAX_PLAYERS];
new wbooboo[MAX_PLAYERS];
pawn Code:
if (strcmp("/buybooboo", cmdtext, true, 10) == 0)
    {
        // your script bla bla
        bbooboo[playerid] = 1;//now this will make you know if he bought
        return 1;
    }
    if (strcmp(" /wearbooboo", cmdtext, true, 10) == 0)
    {
        // your script bla bla
        wbooboo[playerid] = 1;//now this will make you know if he wears it.
        return 1;
    }
Now if you want him to only buy this bla bla once
pawn Code:
if (strcmp("/buybooboo", cmdtext, true, 10) == 0)
    {
        if(bbooboo[playerid] == 1)return SendClientMessage(playerid,-1,"Dude wtf you already bought one");//he won't be abl to buy an other one unless he uses this one
        // your script bla bla
        bbooboo[playerid] = 1;//now this will make you know if he bought
        return 1;
    }
Now when he wears that bla bla He'll have to buy an other one
pawn Code:
if (strcmp(" /wearbooboo", cmdtext, true, 10) == 0)
    {
        if(bbooboo[playerid] == 0)return SendClientMessage(playerid,-1,"You don't have a bbooboo to wear");//in case he doesn't have a blabla
        bbooboo[playerid] = 0;//this will make him lose a bla bla
        // your script bla bla
        wbooboo[playerid] = 1;//now this will make you know if he wears it.
        return 1;
    }
If your looking for an other way of using those tell me.
+ rep thx, helped me with using variables