AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   help with origin (https://forums.alliedmods.net/showthread.php?t=106941)

SCHWEDEN 10-20-2009 17:12

help with origin
 
PHP Code:

public hook_ResetHUD(iClient)
{
    if(
task_exists(iClient))
        
remove_task(iClient);
    static 
newangle[3]
    
get_user_originiClientnewangle )
    
gSpawnPosition[iClient][0] = newangle[0];
    
gSpawnPosition[iClient][1] = newangle[1];
    
gSpawnPosition[iClient][2] = newangle[2];
}

public 
hook_DeathMsg()
{
    new 
iVictim read_data(2);
    
lol(iVictim);
   
}

public 
lol(iClient)
{
    static 
newangle[3];
    
get_user_originiClientnewangle );
    
gDeathPosition[iClient][0] = newangle[0];
    
gDeathPosition[iClient][1] = newangle[1];
    
gDeathPosition[iClient][2] = newangle[2];
    
    if(
abs(gDeathPosition[iClient][0] != gSpawnPosition[iClient][0]) && abs(gDeathPosition[iClient][1] != gSpawnPosition[iClient][1])){
something here


Can you find anything wrong here? Its not working for me. It's a private plugin so I would like to not share the whole code.
Thank you for your time!

vittu 10-20-2009 21:29

Re: help with origin
 
I didn't really look at it, but just a note:

Code:

    if(task_exists(iClient))
        remove_task(iClient);

Don't check if the tasks exists just remove it.

-----

Also you don't really need to:
Code:

    static newangle[3]
    get_user_origin( iClient, newangle )
    gSpawnPosition[iClient][0] = newangle[0];
    gSpawnPosition[iClient][1] = newangle[1];
    gSpawnPosition[iClient][2] = newangle[2];

Just do:
Code:

get_user_origin( iClient,  gSpawnPosition[iClient])

stupok 10-20-2009 22:22

Re: help with origin
 
This doesn't make sense:

Code:

abs(gDeathPosition[iClient][0] != gSpawnPosition[iClient][0])
abs() takes the absolute value of the parameter.

For example,

abs(-3) = 3
abs(0) = 0
abs(3) = 3

The result of "x != y" is either 0 or 1, so it does not make sense to pass it into abs().

Hawk552 10-20-2009 22:33

Re: help with origin
 
You should either use xs_vec_equal() or do a Google search on "Epsilon float precision".

SCHWEDEN 10-21-2009 06:22

Re: help with origin
 
Thanks alot, will try your tips!


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

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