[HELP] lighters and cigars
#1

Hello. Is it possible to make when player buy one lighter and 10 cigars then he can use that one lighter until he smoke all 10 cigars then when it does he must buy another one? I hope so that you understand me? Thanks
Reply
#2

You can do something like:
pawn Код:
new PlayerLight[MAX_PLAYERS];
new Cigars[MAX_PLAYERS];
and then when a player buy cigars:
pawn Код:
Cigars[playerid] = Cigarshere;
PlayerLight[playerid] = 10;
and when a player use a lighter to light one cigar:
pawn Код:
Cigars[playerid] --;
PlayerLight[playerid] --;
and when a player is out of a lighter and try to smoke a cigars:
pawn Код:
if(PlayerLight[playerid] == 0) return SendClientMessage(playerid,-1,"You have to buy a lighter again to smoke more!");
Reply
#3

You get me wrong why you put lighter 10 I want to player buy just one lighter and for example 10 cigars and then he use that one lighter until he smoke all cigars then he buy another one lighter.
Reply
#4

Quote:
Originally Posted by Luca12
Посмотреть сообщение
You get me wrong why you put lighter 10 I want to player buy just one lighter and for example 10 cigars and then he use that one lighter until he smoke all cigars then he buy another one lighter.
He didn't mean you give the player 10 lighters.
What he posted means the player will be able to light 10 times, when he gets to 0, you will ask him to buy a new one.
Then just set PlayerLight[playerid] = 10;
Reply
#5

so do you want to buy 1 lighter for example, and you can use it for 10 times only?
or you can use it until you are out of cigars?
if so then try mine it will work
Reply
#6

Sorry eth I was wrong. Thanks I will try it

edit: I was make also variable when player buy a lighter

PlayerInfo[playerid][Lighter] = 1;

and then in command /smoke how can I change only when player light 10 times then ge het variable Lighter on 0 then he must buy another lighter if you know what I mean? Thanks
Reply
#7

Hey!

You mean if player press mouse left button, his/her smoke one cigar with lighter and if lighter is used 5 times when he cant use anymore and lighter will be removed from player and he needs buy new one. Its correct way ?
Reply
#8

the variable should be PlayerInfo[playerid][Lighter] = 10; at first
and each time he use /smoke do:

pawn Код:
PlayerInfo[playerid][Lighter] --;
and on your command /smoke put:
pawn Код:
if(PlayerInfo[playerid][Lighter] == 0) return SendClientMessage(playerid,-1,"You have to buy a lighter again to smoke more!");
put it at the start of the command after the {
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)