Once per Death [HELP] -
Sting. - 02.08.2017
Well, guys I need help on some simple code. Well I created a /shop dialog box with weapons and armor. What I need now, is for players not to abuse the Armor that can be bought from the /shop. At Dialog response, I use SetPlayerArmour but what I need help now is, how do I set it to that the player can only buy Armor once per life, and only after death they can buy again. For example, in 1 life, they can't buy more than once. How do I do that?
All help will be appreciated and rewarded with
+REP. Thanks, in advance.
Re: Once per Death [HELP] -
Misiur - 02.08.2017
Pretty simple:
1. Create a boolean array of all players
pawn Код:
new bool:ArmourUsed[MAX_PLAYERS char] = { false, ... };
2. When player buys armour, set his state
pawn Код:
ArmourUsed{playerid} = true;
3. When player wants to buy armour again, check if he already did it
pawn Код:
if (ArmourUsed{player}) return rejectOrSomething();
4. Reset his state on spawn or wherever you want
pawn Код:
public OnPlayerSpawn(playerid)
{
// (...)
ArmourUsed{playerid} = false;
// (...)
}
And you are done!
Re: Once per Death [HELP] -
jlalt - 02.08.2017
I don't think you can store boolean value inside a char. ;-; [ just did some tests / prints found result wasn't correct. ], may you double check that?
PHP код:
new bool:WhatBro[20 char] = {true, ...};
public OnFilterScriptInit()
{
for(new i = 0; i < 20; i++)
{
printf("%s - %d",(WhatBro{i}) ? ("True") : ("False"), i);
}
}
result:
PHP код:
False - 0
False - 1
False - 2
True - 3
False - 4
False - 5
False - 6
True - 7
False - 8
False - 9
False - 10
True - 11
False - 12
False - 13
False - 14
True - 15
False - 16
False - 17
False - 18
True - 19
Re: Once per Death [HELP] -
Sting. - 02.08.2017
I'll wait. The help is really much appreciated guys. Will REP you once this matter is solved.
Re: Once per Death [HELP] -
Misiur - 02.08.2017
Oh shit, sorry - it can hold a bool, just array initialization does not work. So, all you need for OP's question is
pawn Код:
new bool:ArmourUsed[MAX_PLAYERS char];
as all values will be false anyway.
If you need set all to true, you have to do it by hand:
pawn Код:
new bool:WhatBro[20 char];
main()
{
for(new i = 0; i < 20; i++) WhatBro{i} = true;
}
Re: Once per Death [HELP] -
Misiur - 02.08.2017
@jlalt: I've thought of a different idea:
pawn Код:
#define CHAR_TRUE bool:cellmax
new bool:WhatBro[20 char] = { CHAR_TRUE, ... };