[FilterScript] San Andreas Singleplayer cheats[cmd based and text based]
#18

I'm afraid it's too inefficient.

First of all, you're using an ENUM for a SINGLE variable

pawn Код:
enum cInfo
{
bool:CanUseCheats
}
new Cheats[MAX_PLAYERS][cInfo];
CAN simply be

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;
        }
}
Can simply be

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;
}
IS PLAIN WRONG

because

pawn Код:
public EndCheat(playerid)
{
        TextDrawHideForPlayer(playerid, cheattd);
        return 1;
}
has a parameter.

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;
}
this
to
pawn Код:
stock CheatTD(playerid)
{
        TextDrawShowForPlayer(playerid, cheattd);
        SetTimerEx("EndCheat", 5000, false, "d", playerid);
        return 1;
}
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
Reply


Messages In This Thread
San Andreas Singleplayer cheats[UPDATED TO V2.0] - by Rayan_black - 04.05.2013, 10:39
Re: San Andreas Singleplayer cheats[cmd based and text based] - by JaKe Elite - 04.05.2013, 10:42
Re : San Andreas Singleplayer cheats[cmd based and text based] - by Rayan_black - 04.05.2013, 10:43
Re: San Andreas Singleplayer cheats[cmd based and text based] - by Hoss - 04.05.2013, 10:50
Re : San Andreas Singleplayer cheats[cmd based and text based] - by Rayan_black - 04.05.2013, 10:51
Re: San Andreas Singleplayer cheats[cmd based and text based] - by JSkulloz - 04.05.2013, 10:54
Re: San Andreas Singleplayer cheats[cmd based and text based] - by Jasem - 04.05.2013, 10:55
Re : San Andreas Singleplayer cheats[cmd based and text based] - by Rayan_black - 04.05.2013, 11:16
Re: San Andreas Singleplayer cheats[cmd based and text based] - by MP2 - 04.05.2013, 11:26
Re : Re: San Andreas Singleplayer cheats[cmd based and text based] - by Rayan_black - 04.05.2013, 11:37
Re: San Andreas Singleplayer cheats[cmd based and text based] - by exodus94 - 04.05.2013, 11:42
Re: San Andreas Singleplayer cheats[cmd based and text based] - by billy123321 - 04.05.2013, 20:01
Re : San Andreas Singleplayer cheats[cmd based and text based] - by tik.tok.rok - 04.05.2013, 20:59
Re: San Andreas Singleplayer cheats[cmd based and text based] - by Strier - 04.05.2013, 22:18
Re : San Andreas Singleplayer cheats[cmd based and text based] - by Rayan_black - 04.05.2013, 22:19
Re: San Andreas Singleplayer cheats[cmd based and text based] - by CaGamingLTD - 05.05.2013, 01:55
Re: San Andreas Singleplayer cheats[cmd based and text based] - by ahmad95 - 05.05.2013, 04:41
Re: San Andreas Singleplayer cheats[cmd based and text based] - by CreativityLacker - 06.05.2013, 14:50
Re: San Andreas Singleplayer cheats[cmd based and text based] - by ahmad95 - 06.05.2013, 15:43
Re: San Andreas Singleplayer cheats[cmd based and text based] - by Mark_Samp - 06.05.2013, 21:02
Re: San Andreas Singleplayer cheats[cmd based and text based] - by JeffAnder - 07.05.2013, 03:22
Re : San Andreas Singleplayer cheats[cmd based and text based] - by Rayan_black - 07.05.2013, 13:09
Re : San Andreas Singleplayer cheats[cmd based and text based] - by Rayan_black - 07.05.2013, 19:12
AW: San Andreas Singleplayer cheats[cmd based and text based] - by Mellnik - 07.05.2013, 19:20
Re : San Andreas Singleplayer cheats[cmd based and text based] - by Rayan_black - 07.05.2013, 19:28
Re: San Andreas Singleplayer cheats[cmd based and text based] - by Furious51 - 08.03.2014, 00:30
Re: San Andreas Singleplayer cheats[cmd based and text based] - by AiRaLoKa - 09.06.2014, 03:35

Forum Jump:


Users browsing this thread: 1 Guest(s)