max c4s
#1

hey i want to know how to make a max_c4s i did something similar b4 but not when you buy
i need when you buy 10 c4s or 2 if it reachs more than 10 c4s it wont accept it i know i can do if c4s >= 10 tell him he cant but it can occur a bug that u can buy more than 10 c4s.
Reply
#2

bump
Reply
#3

no one know? :v
Reply
#4

Buying 1 C4 at a time:
pawn Код:
// on top
#define MAX_C4_PER_PLAYER 10

new pC4[MAX_PLAYERS];

// when they buy C4
pC4[playerid] ++;

// when they use C4
pC4[playerid] --;

// when they try to buy C4
if((pC4[playerid] + 1) > MAX_C4_PER_PLAYER)
{
    SendClientMessage(playerid, -1, "You can only carry up to "#MAX_C4_PER_PLAYER" at a time.");
}
Buying 2 C4 at a time:
pawn Код:
// on top
#define MAX_C4_PER_PLAYER 10

new pC4[MAX_PLAYERS];

// when they buy C4
pC4[playerid] += 2;

// when they use C4
pC4[playerid] --;

// when they try to buy C4
if((pC4[playerid] + 2) > MAX_C4_PER_PLAYER)
{
    SendClientMessage(playerid, -1, "Error while buying C4, try buying 1!");
}
I don't know how anyone wouldn't know how, it's vastly simple. I would just remind you that this section isn't for requests, but I left you an example above. Enjoy!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)