Useable items
#1

To make useable items.. E.g a phone.. It doesn't neccesarly need to be seen on the player, it could be in their backpack.

Would i use a variable?

example script
pawn Код:
new Phone=0; // No phone


Phone++; // When player buys a phone

//

if(Phone == 1)) // They do have phone
Also if they have say 2 wooden sticks + oil + a lighter could i do...
pawn Код:
{
if(Stick == 2) && (oil == 1) && (lighter == 1))
maketorch;
Stick--;
oil--;
lighter--;
{
else(SendClientMessage(playerid,color,"not enough resources");
}
return 1;
}
Reply
#2

bump
Reply
#3

If player doesn't have phone:
pawn Код:
Phone[playerid] = 0;
Player does have phone:
pawn Код:
Phone[playerid] = 1;
2 Wooden sticks:
pawn Код:
Stick[playerid] = 2;
Adding a stick (+1):
pawn Код:
Stick[playerid]++;
Taking a strick (-1):
pawn Код:
Stick[playerid]--;
Oil and lighter work in the same way as sticks.
pawn Код:
if(Stick >= 2 && oil >= 1 && lighter >= 1)
{
    maketorch;
    Stick = Stick - 2;
    oil--;
    lighter--;
    return 1;
}
else return SendClientMessage(playerid, color, "Not enough resources.");
//etc.
Reply
#4

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
If player doesn't have phone:
pawn Код:
Phone[playerid] = 0;
Player does have phone:
pawn Код:
Phone[playerid] = 1;
2 Wooden sticks:
pawn Код:
Stick[playerid] = 2;
Adding a stick (+1):
pawn Код:
Stick[playerid]++;
Taking a strick (-1):
pawn Код:
Stick[playerid]--;
Oil and lighter work in the same way as sticks.
pawn Код:
if(Stick >= 2 && oil >= 1 && lighter >= 1)
{
    maketorch;
    Stick = Stick - 2;
    oil--;
    lighter--;
    return 1;
}
else return SendClientMessage(playerid, color, "Not enough resources.");
//etc.
Thank you very much man, Rep++
Reply
#5

Also, you can use booleans instead of 0 and 1, this doesnt improve performance or something but it makes visibility easier, in my opinion.

pawn Код:
new bool:Phone = false;

if(Phone) // If Phone is "true"

if(!Phone) // If Phone is "false"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)