AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   register touch (https://forums.alliedmods.net/showthread.php?t=85007)

Miko000000 02-04-2009 09:24

register touch
 
Hello i can switch one code and i

ENGINE
Code:

register_touch("player", "land_mine", "mine_touched")

public mine_touched(id, ent)
{
    if(!get_pcvar_num(mines_enabled))
        return
   
    if(!is_user_alive(id))
        return
   
    explode(ent, 0)
}

FAKEMETA (my code)

Code:

register_forward(FM_Touch,"hook_touch")

public hook_touch(id,ent)
    {
    new classname[32]
    pev(id,pev_classname,classname,31)


    if ( equal(classname, "mine_touched"))
    {
    if(!get_pcvar_num(mines_enabled))
    return FMRES_IGNORED;

    if(!is_user_alive(id))
    return FMRES_IGNORED;

    ent("land_mine", 0)

    return FMRES_IGNORED;

    }
    return FMRES_IGNORED;
}

MY code doesn´t work

TheRadiance 02-04-2009 09:36

Re: register touch
 
I'm not good in FM, but i see and can't understand this:

Quote:

ent("land_mine", 0)
Please post all your code.

Miko000000 02-04-2009 09:37

Re: register touch
 
my code have got 4000 lines :(

TheRadiance 02-04-2009 09:40

Re: register touch
 
Ok, post "ent("land_mine", 0)" function and tell, what your part of this script must do.

Miko000000 02-04-2009 09:50

Re: register touch
 
sorry it must be explode("land_mine", 0)

Dr.G 02-04-2009 10:37

Re: register touch
 
PHP Code:

register_forward(FM_Touch,"hook_touch"

PHP Code:

public hook_touch(ptr,id)
{
 if(
get_pcvar_num(p_enable) && is_user_connected(id) && is_user_alive(id))
 {
  static 
szClassName[32]
  
pev(ptrpev_classnameszClassNamesizeof szClassName 1)
  
  if(!
equal(szClassName"YOUR_CLASSNAME"))
   return 
FMRES_IGNORED
  
// do something, explode function ?????
  
 
}
 return 
FMRES_IGNORED



Sn!ff3r 02-04-2009 11:18

Re: register touch
 
Quote:

is_user_connected(id) && is_user_alive(id)


Replace with
Code:

is_user_alive(id)

Miko000000 02-04-2009 11:27

Re: register touch
 
I do this

Code:

public hook_touch(ptr,id)
{
    if(get_pcvar_num(p_enable) && is_user_alive(id))
    {
    static szClassName[32]
    pev(ptr, pev_classname, szClassName, sizeof szClassName - 1)
 
    if(!equal(szClassName, "YOUR_CLASSNAME"))
    return FMRES_IGNORED
   
    if(!get_pcvar_num(mines_enabled))
        return
   
    if(!is_user_alive(id))
        return
   
    explode(ent, 0)
   
    }
    return FMRES_IGNORED
}

sorry i dont know what is classname
and there is messange

Code:

Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

Error: Undefined symbol "p_enable" on line 4156
Warning: Function "hook_touch" should return a value on line 4167
Warning: Function "hook_touch" should return a value on line 4170
Error: Undefined symbol "ent" on line 4170
Warning: Expression has no effect on line 4170
Error: Expected token: ";", but found ")" on line 4170
Error: Invalid expression, assumed zero on line 4170
Error: Too many error messages on one line on line 4170

Compilation aborted.
5 Errors.
Could not locate output file C:\pluginy\MZ\hns.amx (compile failed).


Dr.G 02-04-2009 11:57

Re: register touch
 
p_enabled was i pointer i used, and yours is not p_enabled if i look in your first post thats mines_enabled, and YOUR_CLASSNAME is the class name of your mine. Not YOUR_CLASSNAME unless you used YOUR_CLASSNAME as classname for your mines or what it is...

Quote:

Error: Undefined symbol "ent" on line 4170
Warning: Expression has no effect on line 4170
Error: Expected token: ";", but found ")" on line 4170
Error: Invalid expression, assumed zero on line 4170
Error: Too many error messages on one line on line 4170
That will proberbly mean that u are missing an ) somewhere in line 4170. However i dont think u got the basic knowledge about coding since u post something like that. If u want more help attach your sma here since its 4000 lines +

Cheers!

Miko000000 02-04-2009 12:36

Re: register touch
 
yea im 13 y o people and i starting learn pawn and im beginer and i dont understand syntaxs. and I fix it any method and THANX A LOT


All times are GMT -4. The time now is 01:38.

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