Q: GetPlayerWeapon and Detonator
#1

Is it possible to check if player has detonator (weapon id 40) with GetPlayerWeapon or in any other way?
Reply
#2

ye it is Possible
Reply
#3

Quote:
Originally Posted by BlackFoX_UD_
ye it is Possible
Yes but how?
Reply
#4

Код:
if(GetPlayerWeapon(playerid) == 40)return SendClientMessage(playerid,0xFF0000FF,"The Player have a Detonater!");
Reply
#5

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
Reply
#6

Код:
if((newkeys & KEY_FIRE) && (GetPlayerState(playerid) == 1) && GetPlayerWeapon(playerid) == 40)
{
// Do Something...
}
Reply
#7

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
Reply
#8

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
Reply
#9

oh srry i didnt read all posts
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)