AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] FM_Touch - Grenade Touched a player (https://forums.alliedmods.net/showthread.php?t=253210)

Brow 12-17-2014 18:08

[Help] FM_Touch - Grenade Touched a player
 
Hi,
the following code doesn't work, but i can't discover why.

PHP Code:

public FakeMetaTouch(iEntid)
{
       if(!
pev_valid(iEnt) || !(<= id <= 32))
             return 
FMRES_IGNORED
 
       
static Ent[32], ClassePlayer[32]; new Float:origin[3];
 
       
pev(iEntpev_classnameEnt31);
       
pev(idpev_classnameClassePlayer31);
       
pev(iEntpev_originorigin);
 
       if(
equali(Ent"Presente") && equali(ClassePlayer"player")) // This one works
       
{
            if(
is_user_alive(id))
            {
                  
ColorChat(idGREEN"[Tag Here] ^3Voce tocou no presente e ganhou 5 XP");
                  
ColorChat(0GREEN"Alguem pegou o presente");
                  
PlayerXP[id] += 5;
 
                  
engfunc(EngFunc_RemoveEntityiEnt);
 
            } 
       }
       else if(
equali(Ent"grenade") && equali(ClassePlayer"player")) // The problem begins here, it never execute
       

             new 
Dono pev(iEntpev_owner)
 
             if(
is_user_alive(Dono) && is_user_alive(id))
             {
                     if(
cs_get_user_team(Dono) != cs_get_user_team(id))
                     {
                            
ColorChat(0GREEN"Someone touched");
 
                            
ExecuteHamB(Ham_KilledidDono1);
                     }
             }
       }
       else if(
equali(Ent"grenade")) // It doesn't work too
       
{
               
ColorChat(0GREEN"Touched something, but not a player");
       }
 
       
ColorChat(0GREEN"Classe iEnt: %s, Classe Player: %s"EntClassePlayer); // It never shows "grenade"
 
       
return FMRES_IGNORED;


More information:

What i want to do is something like the "Snowball war", when the grenade touches another player it kills him. I Tried to look in the source code of that plugin, but with no success;
You can find the plugin here (SnowBall War) https://forums.alliedmods.net/showthread.php?p=735477
In the ColorChat messages, it never showed "grenade" or something like this, but it showed the "Presente" classname and also showed "weaponbox" when i took a weapon;
It compiles fine, no errors and no warnings;
"Presente" is an Entity that i created in another part of the plugin (Presente = gift).
I Also tried with Ham_Touch and register_touch

Thanks.

meTaLiCroSS 12-17-2014 20:58

Re: [Help] FM_Touch - Grenade Touched a player
 
Use register_touch from engine instead of fakemeta's FM_Touch hook.


All times are GMT -4. The time now is 15:26.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.