Raised This Month: $ Target: $400
 0% 

Prokreedz help


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bad_Bud
Senior Member
Join Date: Oct 2006
Location: The internet
Old 01-17-2007 , 10:08   Re: Prokreedz help
Reply With Quote #6

I added a velocity check into your existing function, so you can just copy and paste over what you already have.

What this does: gets the player's velocity vector, and checks the Z value for vertical motion(X is 0, Y is 2, Z is 2). I figured you might want to have it check for if they've jumped as well, because if they can't checkpoint while crouched, I doubt you want them checkpointing while jumping. If their Z velocity is 0, clearly they aren't on the ground. In another way, you could also check to see if FL_ONGROUND is true on a player. If they aren't on ground, clearly something is amuck.

PHP Code:
public checkpoint(id) {
 if(
get_pcvar_num(kz_checkpoints) == 1) {
  if(
is_user_alive(id)) {
   new 
Float:velocity[3]
   
entity_get_vector(id,EV_VEC_velocity,velocity)
   
   
entity_get_vector(id,EV_VEC_origin,new Float:origin[3])
   if(
entity_get_int(id,EV_INT_flags)&FL_DUCKING) {
    
client_print(id,print_chat,"[ProKreedz] You can not create a checkpoint while ducking")
    return 
PLUGIN_HANDLED
   
}
   else if(
velocity[2]!=0)
   {
    
client_print(id,print_chat,"[ProKreedz] You must be on the ground to create a checkpoint")
    return 
PLUGIN_HANDLED
   
}
   
   for(new 
i=MAX_CPS-1;i>0;i--) {
    
checkpoints[id-1][i][0] = checkpoints[id-1][i-1][0]
    
checkpoints[id-1][i][1] = checkpoints[id-1][i-1][1]
    
checkpoints[id-1][i][2] = checkpoints[id-1][i-1][2]
   }
   new 
Float:origin[3]
   
entity_get_vector(id,EV_VEC_origin,origin)
   
checkpoints[id-1][0][0] = origin[0]
   
checkpoints[id-1][0][1] = origin[1]
   
checkpoints[id-1][0][2] = origin[2]
   
   if(
checkpointnum[id-1] > 0)
    
client_print(id,print_chat,"[ProKreedz] Checkpoint no. %d created, distance to the previous one: %dm",checkpointnum[id-1]+1,floatround(get_distance_f(checkpoints[id-1][1],origin) / 20,floatround_round))
   else
    
client_print(id,print_chat,"[ProKreedz] First checkpoint created")
   
checkpointnum[id-1]++
  }
  else
   
client_print(id,print_chat,"[ProKreedz] You have to be alive to use this function")
 }
 else
  
client_print(id,print_chat,"[ProKreedz] Checkpoints are disabled")
 
 return 
PLUGIN_HANDLED

__________________
Bad_Bud is offline
 



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 22:21.


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