PDA

View Full Version : Ask about Cmd with quota


[IND]Crazy
16/04/2014, 05:37 PM
i wanna create Cmd with quota ,
examplae i got 1 ticket in payday , and max ticket is 5
and when i have 5 ticket and i use for cmd needed 1 ticket so it will decrease 1 ticket so i have 4 ticket now
and when i have 0 ticket and use cmd with needed 1 ticket it will be show error message .
and it will be saved , example before iam logout my ticket is 2 and when i logout and login back the ticket still 2 .
anyone can help ?


Sorry for my bad english .

Firewire
16/04/2014, 05:47 PM
What you're asking for may be considered a big job. What I mean by that is, you haven't said what saving system you're using and you haven't even begun to explain what command processor you require.

I suggest writing a post on here: http://forum.sa-mp.com/showthread.php?t=413556
People will help you out.

All the best,
Firewire.

[IND]Crazy
16/04/2014, 05:54 PM
i use dini , maybe example for cmd /heal and if player use that the ticket will be decrease 1 ticket
example command

CMD:heal(playerid,params[]) {
#pragma unused params
If(PlayerInfo[playerid][Ticket] == 1) {
SetPlayerHealth(playerid, 100);
PlayerInfo[playerid][Ticket] = -1; //this will be decrease 1 ticket when use this cmd
} else return SendClientMessage(playerid, -1,"You need 1 ticket to use this cmd");
return 1;
}

that just for example
thanks before

Firewire
16/04/2014, 06:06 PM
Okay so you managed to get that working. But remember for the command, you must check if PlayerInfo[playerid][Ticket] is greater than one, not equal to one. As it'll only work when PlayerInfo[playerid][Ticket] has a value of 1.

For Saving:

// Save
dini_Set(File, "Tickets", PlayerInfo[playerid][Ticket]); // Change File to match yours.


Loading:

// Loading
PlayerInfo[playerid][Ticket] = dini_Get(File, "Tickets"); // Change File to match yours.


All the best,
Firewire.

Mauzen
16/04/2014, 06:17 PM
CMD:heal(playerid,params[]) {
#pragma unused params
If(PlayerInfo[playerid][Ticket] == 1) {
SetPlayerHealth(playerid, 100);
PlayerInfo[playerid][Ticket] = -1; //this will be decrease 1 ticket when use this cmd
} else return SendClientMessage(playerid, -1,"You need 1 ticket to use this cmd");
return 1;
}


Its not even THAT wrong. Its wrong, but its pretty close to how you would do it. I wonder why you ask for it here, instead of learning a bit more about pawn, seems like you already got a general idea. (Else I wouldnt reply here ;) )


CMD:heal(playerid,params[]) {
#pragma unused params
If(PlayerInfo[playerid][Ticket] >= 1) { // You also want that command to work with more than one ticket, not just with exactly one
SetPlayerHealth(playerid, 100);
PlayerInfo[playerid][Ticket] = PlayerInfo[playerid][Ticket] - 1; // actually decrease it, else it will just be set to -1
} else return SendClientMessage(playerid, -1,"You need 1 ticket to use this cmd");
return 1;
}


To increase it on every payday, youll have to add something like this to your payday code. I cant tell you where exactly this is.


// Just increase the amount of tickets when the player currently has less than 5
// so it wont go above 5 tickets
if (PlayerInfo[playerid][Ticket] < 5) {
PlayerInfo[playerid][Ticket] = PlayerInfo[playerid][Ticket] + 1;
}

You might also need to add 'Ticket' to the 'PlayerInfo' enum (incase these actually are your variable names, and not just examples). Find the enum that PlayerInfo uses, and just add it to that list, not much to do wrong about this.

[IND]Crazy
17/04/2014, 06:55 AM
Thanks Firewire and Mauzen its worked .
Rep +1 Given .