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



[Solved]OnPlayerKeyState - Saliim - 13.05.2016

Hi, i have a problem with my system,

Код:
	if (newkeys == KEY_YES)
	{
	for(new i = 0; i < sizeof(RecupInfo); i++)
	{
		if (IsPlayerInRangeOfPoint(playerid, 2.0,RecupInfo[i][RecupArmePosX],RecupInfo[i][RecupArmePosY],RecupInfo[i][RecupArmePosZ]))
		{
			if(GetPlayerVirtualWorld(playerid) == RecupInfo[i][RecupArmeVWorld] && GetPlayerInterior(playerid) == RecupInfo[i][RecupArmeVWorld])
			{
   				GetPlayerName(playerid, sendername, sizeof(sendername));
         		DestroyDynamicObject(DropObject[i]);
          		RecupInfo[i][RecupArmePosX] = 0.0;
		    	RecupInfo[i][RecupArmePosY] = 0.0;
		    	RecupInfo[i][RecupArmePosZ] = 0.0;
				RecupInfo[i][RecupArmeAmmount][0] = 0;
				RecupInfo[i][RecupArmeAmmount][1] = 0;
				GivePlayerWeapon(playerid,RecupInfo[i][RecupArmeAmmount][0],RecupInfo[i][RecupArmeAmmount][1]);
				format(string, sizeof(string), "* %s a ramasser des armes.", sendername);
				SendLocalMessage(playerid, string, 10.0, COLOR_ACTION, COLOR_ACTION);
		    	return 1;
			}
		}
	}
with a command, it works, but in a key, it will not fetch arms


Re: OnPlayerKeyState - oMa37 - 13.05.2016

Change

PHP код:
if (newkeys == KEY_YES
To

PHP код:
if((newkeys KEY_YES)) 



Re: OnPlayerKeyState - Logic_ - 13.05.2016

Quote:
Originally Posted by oMa37
Посмотреть сообщение
Change

PHP код:
if (newkeys == KEY_YES
To

PHP код:
if((newkeys KEY_YES)) 
its the same.

EDIT: mistake is here
PHP код:
&& GetPlayerInterior(playerid) == RecupInfo[i][RecupArmeVWorld
change it to
pawn Код:
&& GetPlayerInterior(playerid) == RecupInfo[i][RecupArmeVWorld]
change the vworld into int or interior, as you have in your script.


Re: OnPlayerKeyState - Saliim - 13.05.2016

I think you have not understood.
the buttons work, it is the action that needs to touch that does not work.
he must retrieve the weapons with touche KEY_YES.
the sendlocalmessage work, but it will not fetch arms

ALiScripter, yes, it's the same thing.

oMa37, if u use, if (newkeys == KEY_YES) or if((newkeys & KEY_YES)) the function is the same


Re: OnPlayerKeyState - Konstantinos - 13.05.2016

You set them to 0 and then calling the function when it should be the opposite.
pawn Код:
GivePlayerWeapon(playerid,RecupInfo[i][RecupArmeAmmount][0],RecupInfo[i][RecupArmeAmmount][1]);

RecupInfo[i][RecupArmeAmmount][0] = 0;
RecupInfo[i][RecupArmeAmmount][1] = 0;



Re: OnPlayerKeyState - Saliim - 13.05.2016

oh sh!t, thank you +1