SA-MP Forums Archive
Little Problem - 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: Little Problem (/showthread.php?tid=626228)



Little Problem - MarkNelson - 12.01.2017

Hi Guys, I have a little problem and i tried to fix it many times but i failed. i tried with all my skills but i can't.
Anyway, Here is the error and the line.
but remember i'm trying to to make infecting system not works when player the player is zombie too but it detects the player by his victim color
Here is the lines :
Код:
error 017: undefined symbol "victimid"
Line
Код:
 if(GetPlayerColor(victimid) == COLOR_ZOMBIE)
I hope you to help me guys :/ thank you for reading


Re: Little Problem - AjaxM - 12.01.2017

Did you use SSCANF to define victimid?


Re: Little Problem - MarkNelson - 12.01.2017

yes but not sscanf2.


Re: Little Problem - AjaxM - 12.01.2017

Show us the whole code.


Re: Little Problem - MarkNelson - 12.01.2017

okay
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
    if(newkeys & KEY_WALK) {
        if(GetPlayerSkin(playerid) == 230)
        {
        	ApplyAnimation(playerid, "WAYFARER", "WF_hit", 3.0, 0, 0, 0, 0, 0),PlayerPlaySound(playerid, 1169, 0.0, 0.0, 0.0);
        	new victimid = GetClosestPlayer(playerid);
        	if(GetDistanceBetweenPlayers(playerid,victimid) < 1) {
	         	Infected[playerid]=1;
	    		GameTextForPlayer(playerid,"~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~5",1000,1);
	      		SetPlayerDrunkLevel(victimid,3000);
				return 1;
		    }
		}
        if(GetPlayerColor(victimid) == COLOR_ZOMBIE)
        {
        	   ApplyAnimation(playerid, "WAYFARER", "WF_hit", 3.0, 0, 0, 0, 0, 0),PlayerPlaySound(playerid, 1169, 0.0, 0.0, 0.0);
        	   new victimid = GetClosestPlayer(playerid);
        	   if(GetDistanceBetweenPlayers(playerid,victimid) < 1) {
       	       Infected[playerid]=0;
            }
			   return 1;
               }
        return 1;
        }
    return 1;
}



Re: Little Problem - AjaxM - 12.01.2017

Try this.

PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys) {
    new 
victimid GetClosestPlayer(playerid);
    if(
newkeys KEY_WALK) {
        if(
GetPlayerSkin(playerid) == 230)
        {
            
ApplyAnimation(playerid"WAYFARER""WF_hit"3.000000),PlayerPlaySound(playerid11690.00.00.0);
            if(
GetDistanceBetweenPlayers(playerid,victimid) < 1) {
                 
Infected[playerid]=1;
                
GameTextForPlayer(playerid,"~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~5",1000,1);
                  
SetPlayerDrunkLevel(victimid,3000);
                return 
1;
            }
        }
        if(
GetPlayerColor(victimid) == COLOR_ZOMBIE)
        {
               
ApplyAnimation(playerid"WAYFARER""WF_hit"3.000000),PlayerPlaySound(playerid11690.00.00.0);
               new 
victimid GetClosestPlayer(playerid);
               if(
GetDistanceBetweenPlayers(playerid,victimid) < 1) {
                  
Infected[playerid]=0;
            }
               return 
1;
               }
        return 
1;
        }
    return 
1;




Re: Little Problem - MarkNelson - 12.01.2017

now i found this warning
Код:
C:\Users\infogenie\Documents\Downloads\Compressed\samp037_svr_R2-1-1_win32_4\gamemodes\inf.pwn(746) : warning 219: local variable "victimid" shadows a variable at a preceding level



Re: Little Problem - AjaxM - 12.01.2017

PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys) {
    new 
victimid GetClosestPlayer(playerid);
    if(
newkeys KEY_WALK) {
        if(
GetPlayerSkin(playerid) == 230)
        {
            
ApplyAnimation(playerid"WAYFARER""WF_hit"3.000000),PlayerPlaySound(playerid11690.00.00.0);
            if(
GetDistanceBetweenPlayers(playerid,victimid) < 1) {
                 
Infected[playerid]=1;
                
GameTextForPlayer(playerid,"~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~5",1000,1);
                  
SetPlayerDrunkLevel(victimid,3000);
                return 
1;
            }
        }
        if(
GetPlayerColor(victimid) == COLOR_ZOMBIE)
        {
               
ApplyAnimation(playerid"WAYFARER""WF_hit"3.000000),PlayerPlaySound(playerid11690.00.00.0);
               if(
GetDistanceBetweenPlayers(playerid,victimid) < 1) {
                  
Infected[playerid]=0;
            }
               return 
1;
               }
        return 
1;
        }
    return 
1;




Re: Little Problem - MarkNelson - 12.01.2017

thanks man +REP


Re: Little Problem - MarkNelson - 12.01.2017

man i tested it with my friend but there is a big problem i infect my self not him