Q: GetPlayerWeapon and Detonator - 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: Q: GetPlayerWeapon and Detonator (
/showthread.php?tid=131108)
Q: GetPlayerWeapon and Detonator -
pierhs - 01.03.2010
Is it possible to check if player has detonator (weapon id 40) with GetPlayerWeapon or in any other way?
Re: Q: GetPlayerWeapon and Detonator -
BlackFoX - 01.03.2010
ye it is Possible
Re: Q: GetPlayerWeapon and Detonator -
pierhs - 01.03.2010
Quote:
Originally Posted by BlackFoX_UD_
ye it is Possible
|
Yes but how?
Re: Q: GetPlayerWeapon and Detonator -
BlackFoX - 01.03.2010
Код:
if(GetPlayerWeapon(playerid) == 40)return SendClientMessage(playerid,0xFF0000FF,"The Player have a Detonater!");
Re: Q: GetPlayerWeapon and Detonator -
pierhs - 01.03.2010
i use a bomb system and when a player plants the bomb it gives him a detonator but when he press fire (OnPlayerKeyStateChange) nothing happens
Re: Q: GetPlayerWeapon and Detonator -
BlackFoX - 01.03.2010
Код:
if((newkeys & KEY_FIRE) && (GetPlayerState(playerid) == 1) && GetPlayerWeapon(playerid) == 40)
{
// Do Something...
}
Re: Q: GetPlayerWeapon and Detonator -
DarkPower - 01.03.2010
Quote:
Originally Posted by BlackFoX_UD_
Код:
if(GetPlayerWeapon(playerid) == 40)return SendClientMessage(playerid,0xFF0000FF,"The Player have a Detonater!");
|
This is better
Код:
if(GetPlayerWeapon(playerid) == 40)
{
new
string[128],
name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
format(string,sizeof string,"%s That player have detonator",name);
SendClientMessageToAll(0x00FF0AFF,string);
return 1;
}
i not test but if will have errors post i will fix for you
Re: Q: GetPlayerWeapon and Detonator -
pierhs - 01.03.2010
Its not this.When u press the fire key the detonator is removed and the GetPlayerWeapon is not so fast so it can check it
Re: Q: GetPlayerWeapon and Detonator -
DarkPower - 01.03.2010
oh srry i didnt read all posts
Re: Q: GetPlayerWeapon and Detonator -
help! - 17.03.2010
I found a fix for this.
Since I use pGun1-12 as my server sided weapons, I made it so when someone lays a C4, their pGun12 gets set to 40 (which is detonator). Instead of using
Код:
if(GetPlayerWeapon(playerid) == 40)
{
//explosion shit here
}
I used
Код:
if(PlayerInfo[playerid][pGun12]) //<--- which is only for detonators, no other guns use this slot
{
//explosion shit here
}
And it worked!
I advise you make some sort of "HasDetonator' variable and put in HasDetonator[playerid] = 1; when you give them one so it could work, then use:
Код:
if(HasDetonator[playerid])
{
//explosion shit here
}
EDIT: But you could still punch to detonate the bomb if your HasBomb is set to 1. No big deal to me