SA-MP Forums Archive
OnPlayerKeyStateChange.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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: OnPlayerKeyStateChange.Help (/showthread.php?tid=109586)



OnPlayerKeyStateChange.Help - pierhs - 21.11.2009

I made a cmd /plantbomb so when someone use its it creates an object and it gives him a detonator but the problem is here....I want to the function OnPlayerKeyStateChange when the player press the fire button,an explosion will be created but only if he has a detonator.

Look at this Lines:

First it was like this and it was working but the player was able to do it by punching or something:
Код:
if ((newkeys==KEY_FIRE))
	{
    	DestroyObject(bomb);
    	CreateExplosion(bomb_x[playerid], bomb_y[playerid], bomb_z[playerid], 12, 4.0);
	}
Then I made it like this:

Код:
if ((newkeys==KEY_FIRE && GetPlayerWeapon(playerid) == 40))
	{
    	DestroyObject(bomb);
    	CreateExplosion(bomb_x[playerid], bomb_y[playerid], bomb_z[playerid], 12, 4.0);
	}
But its not working.Help Please!!!


Re: OnPlayerKeyStateChange.Help - pierhs - 21.11.2009

Undefined symbol "GetPlayerArmedWeapon"


Re: OnPlayerKeyStateChange.Help - Sergei - 21.11.2009

GetPlayerWeapon just returns you weapon id in player's active slot. There is GetPlayerWeaponData if you want to get weapon ids and ammo amounts in specific slots.


Re: OnPlayerKeyStateChange.Help - pierhs - 21.11.2009

Yes i use 0.3 also i searched this function at wiki.sa-mp.com and i cant find it


Re: OnPlayerKeyStateChange.Help - pierhs - 21.11.2009

so how can i do it?can u give me the code?


Re: OnPlayerKeyStateChange.Help - Tigerbeast11 - 21.11.2009

Quote:
Originally Posted by pierhs
so how can i do it?can u give me the code?
Not Sure, but try this:

pawn Код:
if (newkeys==KEY_FIRE)
{
  if (GetPlayerArmedWeapon(playerid) == 40)
  {
        DestroyObject(bomb);
        CreateExplosion(bomb_x[playerid], bomb_y[playerid], bomb_z[playerid], 12, 4.0);
  }
}



Re: OnPlayerKeyStateChange.Help - Tigerbeast11 - 21.11.2009

You missed out the "if" BTW, i can read!

pawn Код:
if (GetPlayerWeaponData(playerid, 12, 40, 1))
see?



Re: OnPlayerKeyStateChange.Help - MenaceX^ - 21.11.2009

Quote:
Originally Posted by $ЂЯĢ
GetPlayerWeapon just returns you weapon id in player's active slot. There is GetPlayerWeaponData if you want to get weapon ids and ammo amounts in specific slots.
No, it returns the weapon id of what you're holding.


Re: OnPlayerKeyStateChange.Help - pierhs - 21.11.2009

I get this:
Код:
C:\Documents and Settings\Terminal\ЕрйцЬнейб есгбуЯбт\The Simpsons Roleplay ™\gamemodes\gf.pwn(29479) : error 035: argument type mismatch (argument 3)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.



Re: OnPlayerKeyStateChange.Help - pierhs - 22.11.2009

Its on the same line with this "GetPlayerWeaponData"