Whats wrong with it? Rep +
#1

Код:
[22:09:21] [debug] #0 000181ac in ?? (0x0000ffff, 0x00000000, 0x00000000, 0x40c00000) from SVT_Real.amx
[22:09:21] [debug] #1 0009f940 in ?? (0x00000017, 0x0000ffff, 0x42a50000, 0x00000033, 0x00000003) from SVT_Real.amx
[22:09:21] [debug] #2 00008994 in public OnPlayerTakeDamage (0x00000017, 0x0000ffff, 0x42a50000, 0x00000033, 0x00000003) from SVT_Real.amx


its my OnPlayerTakeDamage
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid,bodypart)
{
	if( GetPlayerTeam(issuerid) == GetPlayerTeam(playerid)){GameTextForPlayer(issuerid, "~r~Team Killing ~y~ Not Allowed", 3000, 3);}
	if(GetPlayerTeam(issuerid) != GetPlayerTeam(playerid)&& pInfo[playerid][GodMode] == 0 && JustSpawned[playerid] == 0 && onduty[playerid] == 0){
			if(issuerid != INVALID_PLAYER_ID && (weaponid == 23 || weaponid == 33 ||  weaponid == 34) && bodypart == 9)
			{
             new Float:Ax, Float:Ay, Float:Az;
             GetPlayerPos(playerid,Ax,Ay,Az);
             blood[playerid] = CreateDynamicObject(18668, Ax, Ay, Az-0.5,0.0,0.0,0.0);
             SetTimerEx("obblood", 5000, false, "fff", Ax, Ay, Az);
             SetPlayerHealth(playerid,0.0);
             SetPVarInt(playerid, "Headshotted", 1);
           	 GameTextForPlayer(playerid, "~r~Headshotted", 3000, 3);
      		}
      		else{
			PlayerPlaySound(issuerid,17802,0.0,0.0,0.0);
		}
			  return 1;
       		 }
 if(JustSpawned[playerid] == 1)
    {
    if(GetPlayerTeam(issuerid) != GetPlayerTeam(playerid))
    {
     new Float:x, Float:y, Float:z;
 	GetPlayerPos(issuerid, x, y, z);
 	SetPlayerPos(issuerid,x,y,z+6);
    GameTextForPlayer(issuerid,"Don't Spawn Kill!",4000,4);
	}
	}
 	return 1;
}

Whats Wrong with it?
Reply
#2

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid,bodypart)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
        if(GetPlayerTeam(issuerid) == GetPlayerTeam(playerid)) GameTextForPlayer(issuerid, "~r~Team Killing ~y~ Not Allowed", 3000, 3);
        else if(!JustSpawned[playerid])
        {
            if(!pInfo[playerid][GodMode] && !onduty[playerid])
            {
                if((weaponid == 23 || weaponid == 33 || weaponid == 34) && bodypart == 9)
                {
                    new Float:Ax, Float:Ay, Float:Az;
                    GetPlayerPos(playerid, Ax, Ay, Az);
                    blood[playerid] = CreateDynamicObject(18668, Ax, Ay, Az - 0.5, 0.0, 0.0, 0.0);
                    SetTimerEx("obblood", 5000, false, "fff", Ax, Ay, Az);
                    SetPlayerHealth(playerid, 0.0);
                    SetPVarInt(playerid, "Headshotted", 1);
                    GameTextForPlayer(playerid, "~r~Headshotted", 3000, 3);
                }
                else PlayerPlaySound(issuerid, 17802, 0.0, 0.0, 0.0);
            }
        }
        else
        {
            new Float:x, Float:y, Float:z;
            GetPlayerPos(issuerid, x, y, z);
            SetPlayerPos(issuerid, x, y, z + 6.0);
            GameTextForPlayer(issuerid, "Don't Spawn Kill!", 4000, 4);
        }
    }
    return 1;
}
If this doesn't work, then I really don't know :l
Reply
#3

it was working Before also But I was Getting these Error

[22:09:21] [debug] #0 000181ac in ?? (0x0000ffff, 0x00000000, 0x00000000, 0x40c00000) from SVT_Real.amx
[22:09:21] [debug] #1 0009f940 in ?? (0x00000017, 0x0000ffff, 0x42a50000, 0x00000033, 0x00000003) from SVT_Real.amx
[22:09:21] [debug] #2 00008994 in public OnPlayerTakeDamage (0x00000017, 0x0000ffff, 0x42a50000, 0x00000033, 0x00000003) from SVT_Real.amx

Thats why ... Ok I will test this..
Reply
#4

pawn Код:
public OnPlayerTakeDamage (0x00000017, 0x0000ffff, 0x42a50000, 0x00000033, 0x00000003)
Translates to:

pawn Код:
public OnPlayerTakeDamage(23, 65535, 1118109696.0, 51, 3)
playerid = 23
issuerid = 65535 = INVALID_PLAYER_ID
amount = 1118109696.0 (I don't think someone took this much damage from an explosion :l
weaponid = 51 = Explosion
bodypart = 3 = BODY_PART_TORSO

So there is a player who is receiving over 1 billion damage from an 'explosion'...?

This is either a hacker somehow doing this, which I haven't recalled seeing before, or you haven't called this callback properly.
Reply
#5

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;
}
Reply
#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
#7

Quote:
Originally Posted by Threshold
Посмотреть сообщение
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.
It's still better then making two local variables.

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

Still more efficient then using if statements.
Also, rather it's 1 or 100 it's just as efficient .

Quote:
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.

CTRL + H - 1 second and all 'Headshooted' is changed to the correct term.
Code wise it's fine yes, However a server with bad grammar will not attract players.
Reply
#8

Quote:

It's still better then making two local variables.

You should only ever create variables where they're necessary. Not just because it makes things easier.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)