AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   native problem (https://forums.alliedmods.net/showthread.php?t=154221)

georgik57 04-04-2011 14:12

native problem
 
1 Attachment(s)
what's wrong here?
i get this error:
http://forums.alliedmods.net/attachm...1&d=1301940724
PHP Code:

// Native: zpnm_get_user_knockback
public native_get_user_knockback(id)
{
    
// ZP disabled
    
if (!g_pluginenabled)
        return -
1;
    
    if (!
is_user_valid_connected(id)
    || !
is_user_valid_alive(id)
    || !
g_zombie[id])
        return 
0;
    
    if (
g_nemesis[id])
        return 
get_pcvar_float(cvar_nemknockback);
    else
        return 
g_zombie_knockback[id];
    
    return 
1;



fysiks 04-04-2011 14:28

Re: native problem
 
1. I see no errors.
2. What line is it. You should post details when you ask questions.

georgik57 04-04-2011 14:35

Re: native problem
 
Quote:

Originally Posted by fysiks (Post 1444443)
1. I see no errors.
2. What line is it. You should post details when you ask questions.

the 2 lines are:
PHP Code:

return get_pcvar_float(cvar_nemknockback); 

PHP Code:

return g_zombie_knockback[id]; 


lis_16 04-04-2011 15:23

Re: native problem
 
PHP Code:

return get_pcvar_float(cvar_nemknockback); 

Should return an intergral value, not a float.

georgik57 04-04-2011 16:11

Re: native problem
 
Quote:

Originally Posted by lis_16 (Post 1444483)
PHP Code:

return get_pcvar_float(cvar_nemknockback); 

Should return an intergral value, not a float.

well i need to return it as a float
it's the gravity multiplier (ex: 0.5 * 800) so i can't just have a integral number
how can i do that?
help please. thanks

matsi 04-04-2011 16:19

Re: native problem
 
Quote:

Originally Posted by georgik57 (Post 1444505)
well i need to return it as a float
it's the gravity multiplier (ex: 0.5 * 800) so i can't just have a integral number
how can i do that?
help please. thanks

Make sure your cvar is float. I think you have integer value in your cvar but you're trying to get float value.

georgik57 04-04-2011 16:26

Re: native problem
 
new cvar_nemknockback => new Float:cvar_nemknockback ???
in the rest of the plugin it works as a float without any problems...
also g_zombie_knockback is defined as a float and i get the same error for it too

matsi 04-04-2011 16:30

Re: native problem
 
Quote:

Originally Posted by georgik57 (Post 1444517)
new cvar_nemknockback => new Float:cvar_nemknockback ???
in the rest of the plugin it works as a float without any problems...
also g_zombie_knockback is defined as a float and i get the same error for it too

i mean is your cvar:
my_cvar "1" <-- Int

or

my_cvar "1.0" <-- Float

Emp` 04-04-2011 16:35

Re: native problem
 
Code:

public native_get_user_knockback(id)
->
Code:

public Float:native_get_user_knockback(id)
Code:

return -1
->
Code:

return -1.0
Code:

return 0
->
Code:

return 0.0
Code:

return 1
->
Code:

return 1.0

georgik57 04-04-2011 16:35

Re: native problem
 
Quote:

Originally Posted by matsi (Post 1444522)
i mean is your cvar:
my_cvar "1" <-- Int

or

my_cvar "1.0" <-- Float

yes it is like that
PHP Code:

cvar_nemknockback register_cvar("zp_knockback_nemesis""0.25"

anyway...i think i fixed it
did the following...is it correct? it compiles with no warnings or errors.
PHP Code:

// Native: zpnm_get_user_knockback
public Float:native_get_user_knockback(id)
{
    
// ZP disabled
    
if (!g_pluginenabled)
        return -
1.0;
    
    if (!
is_user_valid_connected(id)
    || !
is_user_valid_alive(id)
    || !
g_zombie[id])
        return 
0.0;
    
    if (
g_nemesis[id])
        return 
get_pcvar_float(cvar_nemknockback);
    else
        return 
g_zombie_knockback[id];
    
    return 
1.0;


EDIT: emp...lol xD
so it is correct right?
glad i figured it out myself ^^
THANK YOU GUYS FOR YOUR HELP. i really appreciate it.


All times are GMT -4. The time now is 14:40.

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