SA-MP Forums Archive
"already defined" - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: "already defined" (/showthread.php?tid=649403)



"already defined" - ivndosos - 08.02.2018

I'm getting this error
Код:
C:\Users\yan\Desktop\LS DM\gamemodes\DBv1.pwn(1478) : error 021: symbol already defined: "OnPlayerTakeDamage"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Funny thing is, I've searched my whole gamemode using ctrl+f and I don't have it defined twice


Re: "already defined" - ISmokezU - 08.02.2018

Have you tried looking at the precise line for it and still nothing? That would be weird indeed.

CTRL + H and enter 1478 and see.


Re: "already defined" - ivndosos - 08.02.2018

Yeah that's line that I work on now, and that's the only callback lol.


Re: "already defined" - ISmokezU - 08.02.2018

Could it be possible that one your includes contain the same callback?


Re: "already defined" - ivndosos - 08.02.2018

These are the only one's I use

Код:
#include <a_samp>
#include <a_mysql>
#include <geolocation>
#include <zcmd>
#include <sscanf2>
#include <foreach>
#include "../include/gl_common.inc"
#include <weapon-config>



Re: "already defined" - PepsiCola23 - 08.02.2018

Quote:
Originally Posted by ISmokezU
Посмотреть сообщение
Have you tried looking at the precise line for it and still nothing? That would be weird indeed.

CTRL + H and enter 1478 and see.
isn`t it ctrl+g to go to a line?


Re: "already defined" - Mugala - 08.02.2018

check your includes dude, especially weapon-config.


Re: "already defined" - ivndosos - 08.02.2018

Okay I just moved the code to OnPlayerDamage, however

What I'm trying to accomplish here is set player color by his hp by value, but the color doesn't change.

maybe I've done something wrong?

Код:
public OnPlayerDamage(&playerid, &Float:amount, &issuerid, &weapon, &bodypart)
{
	new str[150],target, name1[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name2,sizeof(name2));
	GetPlayerName(target, name1,sizeof(name1));
	if(issuerid != INVALID_PLAYER_ID && weapon == 34 && bodypart == 9)
	{
		format(str, sizeof(str), "{c3c33}* %s has just landed a {FFFFFF}head-shot {BCA9F5}on %s's head !", name1, name2);
		SendClientMessageToAll(-1,str);
		SendClientMessage(target, -1, "{BCA9F5}* You got +2 points for headshot");
		GameTextForPlayer(target,"~y~+2", 300,4);
		pInfo[playerid][Points] += 2;
 	}
    new Float:phealth;
    GetPlayerHealth(playerid);
    if(phealth > 100)
    {
	  SetPlayerColor(playerid, COLOR_GREEN);
    }
    if(phealth > 65)
    {
      SetPlayerColor(playerid, COLOR_YELLOW);
    }
    if(phealth > 50)
    {
      SetPlayerColor(playerid, COLOR_ORANGE);
    }
    if(phealth > 40)
    {
      SetPlayerColor(playerid, COLOR_RED);
    }
    new string[50], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
	new Float:health;
	GetPlayerHealth(playerid, health);
    if(playerid != INVALID_PLAYER_ID && issuerid != INVALID_PLAYER_ID)
    {
	  SetTimerEx("Damage", 4000, false, "i", issuerid);
	  format(string, sizeof(string), "{7FFFD4}%.0f damage by %s\n{7FFFD4}%.0f HP left", amount, name, health);
	  SetPlayerChatBubble(playerid, string, -1, 60.0, 3000);
    }
 	return 1;
}



Re: "already defined" - Mugala - 08.02.2018

you must use "else" functions too, or just swap the code from lower-to-upper.

solution 1:
PHP код:
    if(phealth >= 100)
    {
      
SetPlayerColor(playeridCOLOR_GREEN);
    }
    else if(
phealth 65)
    {
      
SetPlayerColor(playeridCOLOR_YELLOW);
    }
    else if(
phealth 50)
    {
      
SetPlayerColor(playeridCOLOR_ORANGE);
    }
    else if(
phealth 40)
    {
      
SetPlayerColor(playeridCOLOR_RED);
    } 
solution 2:
PHP код:
    if(phealth 40)
    {
      
SetPlayerColor(playeridCOLOR_RED);
    }
    if(
phealth 50)
    {
      
SetPlayerColor(playeridCOLOR_ORANGE);
    }
    if(
phealth 65)
    {
      
SetPlayerColor(playeridCOLOR_YELLOW);
    }
    if(
phealth >= 100)
    {
      
SetPlayerColor(playeridCOLOR_GREEN);
    } 
choose one of them, both will work (1st is better)