SA-MP Forums Archive
Infect help!!! - 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: Infect help!!! (/showthread.php?tid=600725)



Infect help!!! - professional killer - 12.02.2016

I have this code for infecting human player when a certain class of zombie presses LALT. I don't know why but this code is not working . Can Someone Please help.....
Код:
if(PRESSED(KEY_WALK))
	{
	    if(team[playerid] == TEAM_ZOMBIE)
	    {
			if(pInfo[playerid][pZombieClass] == MUTATEDZOMBIE)
			{
                if(gettime() - 10 < Abilitys[playerid][AdvancedMutatedCooldown]) return GameTextForPlayer(playerid,"~w~ Still recovering",1000,5);
			    {
					foreach(Player,i)
					{
      					switch(GetPlayerSkin(i))
						{
       						case NON_IMMUNE,70:
							{
                        	    if(GetDistanceBetweenPlayers(playerid,i) < 6.5)
                        	    {
							    	if(pInfo[i][IsPlayerInfected] == 0)
							    	{
										InfectPlayerStandard(i);
										GivePlayerXP(playerid,10);
										GameTextForPlayer(playerid,"~n~~n~~n~~n~~n~~y~+10 XP",3500,5);
										Abilitys[playerid][AdvancedMutatedCooldown] = gettime();
									}
								}
							}
						}
					}
				}
			}
		}
	}



Re: Infect help!!! - K0P - 12.02.2016

Код:
if(PRESSED(KEY_WALK))
	{
	    if(team[playerid] == TEAM_ZOMBIE)
	    {
			if(pInfo[playerid][pZombieClass] == MUTATEDZOMBIE)
			{
                if(gettime() - 10 < Abilitys[playerid][AdvancedMutatedCooldown]) return GameTextForPlayer(playerid,"~w~ Still recovering",1000,5);
                else
			    {
					foreach(Player,i)
					{
      					switch(GetPlayerSkin(i))
						{
       						case NON_IMMUNE,70:
							{
                        	    if(GetDistanceBetweenPlayers(playerid,i) < 6.5)
                        	    {
							    	if(pInfo[i][IsPlayerInfected] == 0)
							    	{
										InfectPlayerStandard(i);
										GivePlayerXP(playerid,10);
										GameTextForPlayer(playerid,"~n~~n~~n~~n~~n~~y~+10 XP",3500,5);
										Abilitys[playerid][AdvancedMutatedCooldown] = gettime();
									}
								}
							}
						}
					}
				}
			}
		}
	}



Re: Infect help!!! - professional killer - 12.02.2016

ohhhh.. Thank you. I forgot to put that "else". I will just try the code.
EDIT: Nah its not working....


Re: Infect help!!! - MatheusOliveira - 12.02.2016

Код:
if(PRESSED(KEY_WALK))
	{
	    if(team[playerid] == TEAM_ZOMBIE)
	    {
			if(pInfo[playerid][pZombieClass] == MUTATEDZOMBIE)
			{
                if(gettime() - 10 < Abilitys[playerid][AdvancedMutatedCooldown]) return GameTextForPlayer(playerid,"~w~ Still recovering",1000,5);
	            }
				else
			    {
					foreach(Player,i)
					{
      					switch(GetPlayerSkin(i))
						{
       						case NON_IMMUNE,70:
							{
                        	    if(GetDistanceBetweenPlayers(playerid,i) < 6.5)
                        	    {
							    	if(pInfo[i][IsPlayerInfected] == 0)
							    	{
										InfectPlayerStandard(i);
										GivePlayerXP(playerid,10);
										GameTextForPlayer(playerid,"~n~~n~~n~~n~~n~~y~+10 XP",3500,5);
										Abilitys[playerid][AdvancedMutatedCooldown] = gettime();
									}
								}
							}
						}
					}
				}
			}
		}
I think he had forgotten something, try now...


Re: Infect help!!! - professional killer - 13.02.2016

No It doesn't work either....


Re: Infect help!!! - Sew_Sumi - 13.02.2016

This is not how to use Scripting Help people.


How do you get PRESSED?


Re: Infect help!!! - professional killer - 13.02.2016

Of course I had put the if case in this one
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)



Re: Infect help!!! - Sew_Sumi - 13.02.2016

This is the problem. Unless you are using that callback properly, no changes anywhere else will do anything.

You'll wanna paste up the section of code that defines PRESSED in OnPlayerKeyStateChange.

If you look around on faults with that callback, the most common is using simply "newkeys", and not both of them.

https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange

Look carefully in the section regarding "How NOT to check for a key" and below that.


Still though, paste up your OnPlayerKeyStateChange if you are still stumped.