Ask about Cmd with quota
#1

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

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: https://sampforum.blast.hk/showthread.php?tid=413556
People will help you out.

All the best,
Firewire.
Reply
#3

i use dini , maybe example for cmd /heal and if player use that the ticket will be decrease 1 ticket
example command
pawn Код:
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
Reply
#4

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:
pawn Код:
// Save
dini_Set(File, "Tickets", PlayerInfo[playerid][Ticket]); // Change File to match yours.
Loading:
pawn Код:
// Loading
PlayerInfo[playerid][Ticket] = dini_Get(File, "Tickets"); // Change File to match yours.
All the best,
Firewire.
Reply
#5

pawn Код:
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 )

pawn Код:
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.

pawn Код:
// 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.
Reply
#6

Thanks Firewire and Mauzen its worked .
Rep +1 Given .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)