storing data?
#1

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
Reply
#2

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.
Reply
#3

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)