Raised This Month: $32 Target: $400
 8% 

Touch positions problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JocAnis
Veteran Member
Join Date: Jun 2010
Old 06-21-2018 , 07:14   Touch positions problem
Reply With Quote #1

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;
    
}

JocAnis is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-21-2018 , 07:22   Re: Touch positions problem
Reply With Quote #2

Get the origin.

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

or fakemeta

Code:
pev( iEnt, pev_origin, fOrigins );
__________________
stuff

Last edited by maqi; 06-21-2018 at 07:23.
maqi is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 06-21-2018 , 07:27   Re: Touch positions problem
Reply With Quote #3

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
JocAnis is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-21-2018 , 07:29   Re: Touch positions problem
Reply With Quote #4

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
__________________
stuff
maqi is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 06-21-2018 , 07:33   Re: Touch positions problem
Reply With Quote #5

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 :/
JocAnis is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-21-2018 , 07:35   Re: Touch positions problem
Reply With Quote #6

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
__________________
stuff
maqi is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 06-21-2018 , 07:42   Re: Touch positions problem
Reply With Quote #7

that will change the whole structure of the code...ill see what to do, thanks anyway
JocAnis is offline
shauli
Member
Join Date: Jun 2018
Old 06-21-2018 , 17:25   Re: Touch positions problem
Reply With Quote #8

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.
shauli is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 06-22-2018 , 06:35   Re: Touch positions problem
Reply With Quote #9

@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)
JocAnis is offline
shauli
Member
Join Date: Jun 2018
Old 06-22-2018 , 10:16   Re: Touch positions problem
Reply With Quote #10

Quote:
Originally Posted by JocAnis View Post
@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] ) 

     } 

shauli is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:24.


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