Whats wrong with it? Rep +
#6

Quote:
Originally Posted by Lynn
Посмотреть сообщение
pawn Код:
new bool: InGodMode[MAX_PLAYERS] = false; // Can only equal 1 or 0 so use bool(True and false)
new bool: AdminDuty[MAX_PLAYERS] = false; // Can only equal 1 or 0 so use bool(True and false)
new bool: JustSpawned[MAX_PLAYERS]= false; // Can only equal 1 or 0 so use bool(True and false)
new Blood[MAX_PLAYERS];

public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
        new// No reason to define X,Y,Z twice for two seperate uses.
            Float:Z,
            Float:Y,
            Float:Z;

        if(GetPlayerTeam(issuerid) == GetPlayerTeam(playerid)) return GameTextForPlayer(issuerid, "~r~Team Killing ~y~ Not Allowed", 3000, 3); // Return values!
        else if(JustSpawned[playerid] == false)
        {
            if(InGodMode[playerid] == false && AdminDuty[playerid] == false)
            {
                if(bodypart == 9)
                {
                    switch(weaponid) // Switch statements are faster then if statements.
                    {
                        case 23, 33, 34:
                        {
                            GetPlayerPos(playerid, X, Y, Z);
                            Blood[playerid] = CreateDynamicObject(18668, X, Y, Z-0.5, 0.0, 0.0, 0.0);
                            SetTimerEx("obblood", 5000, false, "fff", X, Y, Z);
                            SetPlayerHealth(playerid, 0.0);
                            SetPVarInt(playerid, "Headshot", 1); // Headshotted isn't a word.
                            GameTextForPlayer(playerid, "~r~Headshot", 3000, 3); // Headshotted isn't a word.
                        }
                    }
                }
                else return PlayerPlaySound(issuerid, 17802, 0.0, 0.0, 0.0); // Return values!
            }
        }
        else
        {
            GetPlayerPos(issuerid, X, Y, Z);
            SetPlayerPos(issuerid, X, Y, Z+ 6.0);
            GameTextForPlayer(issuerid, "Don't Spawn Kill!", 4000, 4);
        }
    }
    return 1;
}
pawn Код:
new// No reason to define X,Y,Z twice for two seperate uses.
            Float:Z,
            Float:Y,
            Float:Z;
Nor is there any reason to create a variable if they aren't going to be used in some instances. What if the player is on the same team as the person they shot? You will not use X, Y or Z. (Also, you introduced 'z' twice) What if they are not using the weapon 23, 33 or 34? You have created useless variables. What if they weren't shot in the head? You have created useless variables.

pawn Код:
switch(weaponid) // Switch statements are faster then if statements.
                    {
                        case 23, 33, 34:
For 3 cases, the difference is extremely insignificant.

pawn Код:
SetPVarInt(playerid, "Headshot", 1); // Headshotted isn't a word.
                            GameTextForPlayer(playerid, "~r~Headshot", 3000, 3); // Headshotted isn't a word.
This doesn't affect any portion of his code. All that does is make sure he goes through his entire script and mucks around with every single time he uses the function 'Headshotted' to rename it.
Reply


Messages In This Thread
Whats wrong with it? Rep + - by MBilal - 21.01.2015, 03:36
Re: Whats wrong with it? Rep + - by Threshold - 21.01.2015, 04:11
Re: Whats wrong with it? Rep + - by MBilal - 21.01.2015, 04:19
Re: Whats wrong with it? Rep + - by Threshold - 21.01.2015, 04:32
Re: Whats wrong with it? Rep + - by Lynn - 21.01.2015, 04:51
Re: Whats wrong with it? Rep + - by Threshold - 21.01.2015, 05:35
Re: Whats wrong with it? Rep + - by Lynn - 21.01.2015, 06:00
Re: Whats wrong with it? Rep + - by Threshold - 22.01.2015, 04:47

Forum Jump:


Users browsing this thread: 1 Guest(s)