06.05.2013, 14:50
I'm afraid it's too inefficient.
First of all, you're using an ENUM for a SINGLE variable
CAN simply be
ANND
Can simply be
ALSOOOOO
IS PLAIN WRONG
because
has a parameter.
And using TIMERS with parameters requires you to use SetTimerEx
SOOO
we change
this
to
BUT, I do like the idea of implementing the single-player cheats like this using OnPlayerText.
Some points I'd like to see improved -
Better indentation
Usage of array's
custom cheat ID's
permissions for using EACH cheat SEPARATELY for each player
First of all, you're using an ENUM for a SINGLE variable
pawn Код:
enum cInfo
{
bool:CanUseCheats
}
new Cheats[MAX_PLAYERS][cInfo];
pawn Код:
new bool:CanUseCheats[MAX_PLAYERS];
ANND
pawn Код:
public OnPlayerText(playerid, text[])
{
if(strcmp("lxgiwyl",text,true,1) == 0 && Cheats[playerid][CanUseCheats] == true)
{
GivePlayerWeapon(playerid, 5, 1);
GivePlayerWeapon(playerid, 22, 999);
GivePlayerWeapon(playerid, 25, 999);
GivePlayerWeapon(playerid, 28, 999);
GivePlayerWeapon(playerid, 35, 999);
GivePlayerWeapon(playerid, 18, 999);
CheatTD(playerid);
return 0;
}
}
pawn Код:
public OnPlayerText(playerid, text[])
{
if(strcmp("lxgiwyl",text,true,1) == 0 && Cheats[playerid][CanUseCheats] == true)
{
cmd_lxgiwyl(playerid, "");
return 0;
}
}
ALSOOOOO
pawn Код:
stock CheatTD(playerid)
{
TextDrawShowForPlayer(playerid, cheattd);
SetTimer("EndCheat", 5000, false);
return 1;
}
because
pawn Код:
public EndCheat(playerid)
{
TextDrawHideForPlayer(playerid, cheattd);
return 1;
}
And using TIMERS with parameters requires you to use SetTimerEx
SOOO
we change
pawn Код:
stock CheatTD(playerid)
{
TextDrawShowForPlayer(playerid, cheattd);
SetTimer("EndCheat", 5000, false);
return 1;
}
to
pawn Код:
stock CheatTD(playerid)
{
TextDrawShowForPlayer(playerid, cheattd);
SetTimerEx("EndCheat", 5000, false, "d", playerid);
return 1;
}
Some points I'd like to see improved -
Better indentation
Usage of array's
custom cheat ID's
permissions for using EACH cheat SEPARATELY for each player