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