AlliedModders

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

JocAnis 06-21-2018 07:14

Touch positions problem
 
im trying to make plugin with checkpoints per map, saved in .ini file ect...but i need help, how to determine what exactly position/checkpoint (model) has player touched ? I mean, the present code is working: if players touches first checkpoint he will get printed message for ALL these checkpoints on the map, which is the problem...here is the code...i dont have idea how to code that thing :s

PHP Code:

register_touch("cp_ent""player""touched1"

...
making entity cp_ent...

public 
touched1entid )
{
    for( new 
i=0cp_counti++ )//probably this is wrong, but what better to use ? :/
    
{
        
entity_get_string(entEV_SZ_targetnametargetNamecharsmax(targetName));
        if( 
containitargetNamecp_ents[i] ))
        {
            if( !
run_run[i+1] )
            {
                
run_run[i+1]=true
                Time_igrac 
get_gametime() - cp_time[id][i]
                
                
client_printidprint_chat"You touched: %i; time: %.02f (FILE: %.02f)"i+1Time_igracofficial_time[1][cp_count+1] )

            }
        }
        
//break;
    
}



maqi 06-21-2018 07:22

Re: Touch positions problem
 
Get the origin.

Engine:
Code:
entity_get_vector( iEnt, EV_VEC_origin, fOrigins );

or fakemeta

Code:
pev( iEnt, pev_origin, fOrigins );

JocAnis 06-21-2018 07:27

Re: Touch positions problem
 
that will be the pain in the as* cuz it has to load origins from file + check which one is from the list...i meant if theres any simpler solution

maqi 06-21-2018 07:29

Re: Touch positions problem
 
The only way to determine someones position is the origins, but why would that be a pain ? I can't think of anything that's complex about it.

Let us know if you need any help once you establish the basic code, happy to help :D

JocAnis 06-21-2018 07:33

Re: Touch positions problem
 
i missunderstood. getting the players origin isnt the problem, but with what to 'compare' their origin, when all entities (checkpoints) have the same entity_name, they are different only with cp_count :/

maqi 06-21-2018 07:35

Re: Touch positions problem
 
Compare it with the entity origin then, im not 100% sure what you are trying to achieve, so let me know if i got something wrong

JocAnis 06-21-2018 07:42

Re: Touch positions problem
 
that will change the whole structure of the code...ill see what to do, thanks anyway :)

shauli 06-21-2018 17:25

Re: Touch positions problem
 
When creating your checkpoints entities add some extra information in iuser1/2/3/4, for example inside your for loop:
PHP Code:

set_pev(entpev_iuser1i); 

Then in your touch forward use pev(ent, pev_iuser1) to get that data.

JocAnis 06-22-2018 06:35

Re: Touch positions problem
 
@shauli, thanks for help, but Kushfield helped me and its fixed now...so it went from:

if( containi( targetName, cp_ents[i] ))

to just

if(cp_ents[i-1] == ent)

shauli 06-22-2018 10:16

Re: Touch positions problem
 
Quote:

Originally Posted by JocAnis (Post 2598626)
@shauli, thanks for help, but Kushfield helped me and its fixed now...so it went from:

if( containi( targetName, cp_ents[i] ))

to just

if(cp_ents[i-1] == ent)

That's fine but it's not really necessary, iuser/fuser/vuser exists exactly for the stuff you're trying to do, it will be easier to use it. You don't need a for loop, it will be like this:

PHP Code:

public touched1entid 

    new 
cp pev(entpev_iuser1);

     if( !
run_run[cp] ) //or cp+1, you decide 
     

          
run_run[cp]=true 
          Time_igrac 
get_gametime() - cp_time[id][i
                 
          
client_printidprint_chat"You touched: %i; time: %.02f (FILE: %.02f)"cpTime_igracofficial_time[1][cp_count+1] ) 

     } 




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

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