Search

open.mp forum

RegisterLogin

Discussion

General
Chat
Tech
Life
Art
Programming
open.mp
Development Updates
Questions and Suggestions
SA-MP
General Discussions
Videos and Screenshots
Support
Pawn Scripting
Tutorials
Releases
Plugins
Libraries
Filterscripts
Gamemodes
Maps
Advertisements
Other languages
Spanish/Espa?ol
Programaci?n
Discusi?n GTA SA Multijugador
Mods
Offtopic
Juegos
Portuguese/Portugu?s
Russian/???????
Italian/Italiano
Dutch/Nederlands
German/Deutsch
Romanian/Rom?na
Ex-Yu
Polish/Polski
Og?lne
Serwery
Skryptowanie
Filmiki i zdjecia
Lithuanian/Lietuvi?kas
French/Fran?ais
Hungarian/Magyar
Hindi/Urdu
Turkish
Other
Internal
Team
Hidden
Archived

Library

 Collections Links Members Roles

command usage limit

So I made command /medkit use and buy, when player types /medkit buy, his tokens gets in -, while 1 medkit gets in , problem is...

ID
d6ouivfilegovhg7bbt0
author
unbelievable_10's avatar

unbelievable_10

@unbelievable_10


View profile
Copy link
  Report member
started
Jul 1, 2019
replies
0
participating
No

scroll to top

powered by storyden

Login
Discussion
Pawn Scripting
command usage limit
unbelievable_10's avatar

unbelievable_10

@unbelievable_10


View profile
Copy link
  Report member
• 6y
Pawn Scripting

command usage limit

pawn

So I made command /medkit use and buy, when player types /medkit buy, his tokens gets in -, while 1 medkit gets in , problem is that I put limit that they can use /medkit buy max 3 times and so that they cannot abuse it, but when they buy all 3 medkits, it will say "You can't buy more medkits this round!", when they use /medkit use, they will get Medkit -1, and they will have 2 medkits, which will make them to be ABLE to buy the medkit again and again and again if you understand, so I want to make that they can only write /medkit buy 3 times and when they spend third medkit that they cannot again buy it, how to fix? thanks

CMD:medkit(playerid, params[])
{
 ? ?new Float:HP;
 ? ?GetPlayerHealth(playerid, HP);
 ? ?if(playerTazed[playerid] == true || playerCuffed[playerid] == true || !IsPlayerSpawned(playerid) || playerWounded[playerid] > 0) return SFM(playerid, COLOR_ACMD, "[!] You cannot use this right now!");
 ? ?if(PlayerInfo[playerid][inGame] == false) return SFM(playerid, COLOR_ACMD, "[!] {FFFFFF}You're not in the copchase!");
 ? ?new option[256];
 ? ?if(sscanf(params, "s[256]", option)) return SFM(playerid, COLOR_USAGE, "[USAGE] medkit <mymedkits/buy/use/help>");
 ? ?if(!strcmp(option, "mymedkits"))
 ? ?{
 ? ?SFM(playerid, COLOR_ACMD, "[!] {FFFFFF}You currently have {FF6347}[{FFFFFF}%d{FF6347}] {FFFFFF}medkits!", PlayerInfo[playerid][MedKit]);
 ? ?}
 ? ?else if(!strcmp(option, "buy"))
 ? ?{ 
 ? ?if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER && GetPlayerState(playerid) != PLAYER_STATE_PASSENGER) return SFM(playerid, COLOR_ACMD, "[!] {FFFFFF}You can only buy medkits as a driver/passenger!");
 ? ?if(PlayerInfo[playerid][Tokens] < 250) return SFM(playerid, COLOR_ACMD, "[!] {FFFFFF}You dont have enough tokens!");
 ? ?if(PlayerInfo[playerid][MedKit] >= 3) return SFM(playerid, COLOR_ACMD, "[!] {FFFFFF}You can buy max 3 med kits per chase!");
 ? ?PlayerInfo[playerid][Tokens] -= 250;
 ? ?PlayerInfo[playerid][MedKit] = 1;
 ? ?cmd_me(playerid, "grabs some bandages from the vehicle");
 ? ?SFM(playerid, COLOR_ACMD, "[!] {FFFFFF}You've sucessfully bought one medkit for 250 tokens!");
 ? ?}
 ? ?else if(!strcmp(option, "use"))
 ? ?{
 ? ?if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return SFM(playerid, COLOR_ACMD, "[!] {FFFFFF}You can only use medkits while onfoot!");
 ? ?if(gettime() < Cooldown[playerid]) return SFM(playerid, COLOR_ACMD, "[!] {FFFFFF}Please wait before using a medkit again!");
 ? ?if(HP >= 100.0) return SFM(playerid, COLOR_ACMD, "[!] {FFFFFF}You can only use med kits if your health is below 100%!");
 ? ?if(PlayerInfo[playerid][MedKit] == 0) return SFM(playerid, COLOR_ACMD, "[!] {FFFFFF}You have no medkits!");
 ? ?PlayerInfo[playerid][MedKit] -= 1;
 ? ?SetPlayerHealth(playerid, HP);
 ? ?ApplyAnimation(playerid,"MEDIC","CPR",4.1, 0, 1, 1, 1, 5000, 1);
 ? ?SetTimerEx("Unfreeze", 5000, false, "d", playerid);
 ? ?cmd_me(playerid, "bandages himself up.");
 ? ?Cooldown[playerid] = gettime()  30 * 2;
 ? ?SFM(playerid, COLOR_ACMD, "[!] {FFFFFF}You've used one medkit and you've fixed your health for %! You've {FF6347}[{FFFFFF}%d{FF6347}] {FFFFFF}medkits left!", PlayerInfo[playerid][MedKit]);
 }
 else if(!strcmp(option, "help"))
 {
 ? ?return cmd_medkithelp(playerid);
 }
 ? ?return 1;
}
0 likes0 replies

    Please sign up or log in to reply