Raised This Month: $ Target: $400
 0% 

checkpoints problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lirix
Junior Member
Join Date: Nov 2008
Location: Russia
Old 04-16-2009 , 06:45   checkpoints problem
Reply With Quote #1

I modify plugin prokreedz for my purposes.
I encountered a problem with checkpoints.
Code:
public checkpoint(id) {
	if(get_pcvar_num(kz_checkpoints) == 1) {
		if(is_user_alive(id)) {
			if( !(pev(id, pev_flags) & FL_ONGROUND2) ) {
				ColorChat(id,RED,"[KG Jump] You can not create a checkpoint while in air")
				return PLUGIN_HANDLED
			}
			
			if(entity_get_int(id,EV_INT_flags)&FL_DUCKING) {
				ColorChat(id,RED,"[ProKreedz] You can not create a checkpoint while ducking")
				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)
				ColorChat(id,BLUE,"[KG Jump] 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,"[KG Jump] First checkpoint created")
			checkpointnum[id-1]++
		}
		else
			client_print(id,print_chat,"[KG Jump] You have to be alive to use this function")
	}
	else
		client_print(id,print_chat,"[KG Jump] Checkpoints are disabled")
	
	return PLUGIN_HANDLED
}
If I remove checks on the duck, then while keeping the checkpoint with duck, after calling goto_checkpoint can not move.
How can I fix this?


Another code:

Code:
public goto_checkpoint(id) {
	if(get_pcvar_num(kz_checkpoints) == 1) {
		if(is_user_alive(id)) {
			if(checkpointnum[id-1] > 0) {
				if(read_argc() == 2) {
					new szcp[8], cpnum
					read_argv(1,szcp,8)
					cpnum = str_to_num(szcp) - 1
						
					if(cpnum >= 0 && cpnum < MAX_CPS) {
						if(cpnum < checkpointnum[id-1])
							goto_cp(id,cpnum)
						else
							ColorChat(id,RED,"[KG Jump] You have not created enough checkpoints")
					}
					else
						goto_cp(id,0)
				}
				else {
					goto_cp(id,0)
				}
			}
			else
				client_print(id,print_chat,"[KG Jump] First you have to create a checkpoint")
		}
		else
			client_print(id,print_chat,"[KG Jump] You must be alive to use this function")
	}
	else
		client_print(id,print_chat,"[KG Jump] Checkpoints are disabled")
		
	return PLUGIN_HANDLED
}
Code:
public goto_cp(id,cp) {
	new semiclip = get_pcvar_num(kz_semiclip)
	if(semiclip == -1 || (!noblock[id-1] && semiclip == 0)) {
		new Float:origin[3]
		for(new i=1;i<=get_maxplayers();i++) {
			if(id != i && is_user_connected(i) && is_user_alive(id)) {
				if(semiclip == -1 || (!noblock[i-1] && semiclip == 0)) {
					entity_get_vector(i,EV_VEC_origin,origin)
					if(get_distance_f(checkpoints[id-1][cp],origin) <= CP_DISTANCE) {
						client_print(id,print_chat,"[KG Jump] Somebody is too close to your checkpoint")
						return false
					}
				}
			}
		}
	}
	
	entity_set_origin(id,checkpoints[id-1][cp])
	entity_set_vector(id,EV_VEC_velocity,Float:{0.0,0.0,0.0})
	spawnsprite(checkpoints[id-1][cp])
	set_user_gravity(id) // to fix the low gravity bug on kz_man_redrock (thanks to NoEx)
	noblock_task()
	
	return true
}
Code:
public spawnsprite(Float:origin[3]) {
	new iorigin[3]
	iorigin[0] = floatround(origin[0],floatround_ceil)
	iorigin[1] = floatround(origin[1],floatround_ceil)
	iorigin[2] = floatround(origin[2],floatround_ceil)
	
	message_begin(MSG_ALL,SVC_TEMPENTITY)
	write_byte(11)
	write_coord(iorigin[0])
	write_coord(iorigin[1])
	write_coord(iorigin[2])
	message_end()
}
Lirix is offline
vato loco [GE-S]
Veteran Member
Join Date: Oct 2006
Location: Germany
Old 04-16-2009 , 09:40   Re: checkpoints problem
Reply With Quote #2

Code:
public checkpoint(id) {
    if(get_pcvar_num(kz_checkpoints) == 1) {
        if(is_user_alive(id)) {
            if( !(pev(id, pev_flags) & FL_ONGROUND2) ) {
                ColorChat(id,RED,"[KG Jump] You can not create a checkpoint while in air")
                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)
                ColorChat(id,BLUE,"[KG Jump] 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,"[KG Jump] First checkpoint created")
            checkpointnum[id-1]++
        }
        else
            client_print(id,print_chat,"[KG Jump] You have to be alive to use this function")
    }
    else
        client_print(id,print_chat,"[KG Jump] Checkpoints are disabled")
    
    return PLUGIN_HANDLED
}
Code:
public goto_cp(id,cp) {
    new semiclip = get_pcvar_num(kz_semiclip)
    if(semiclip == -1 || (!noblock[id-1] && semiclip == 0)) {
        new Float:origin[3]
        for(new i=1;i<=get_maxplayers();i++) {
            if(id != i && is_user_connected(i) && is_user_alive(id)) {
                if(semiclip == -1 || (!noblock[i-1] && semiclip == 0)) {
                    entity_get_vector(i,EV_VEC_origin,origin)
                    if(get_distance_f(checkpoints[id-1][cp],origin) <= CP_DISTANCE) {
                        client_print(id,print_chat,"[KG Jump] Somebody is too close to your checkpoint")
                        return false
                    }
                }
            }
        }
    }
    delay_duck(id)
    entity_set_origin(id,checkpoints[id-1][cp])
    entity_set_vector(id,EV_VEC_velocity,Float:{0.0,0.0,0.0})
    spawnsprite(checkpoints[id-1][cp])
    set_user_gravity(id) // to fix the low gravity bug on kz_man_redrock (thanks to NoEx)
    noblock_task()
    
    return true
}

delay_duck(id) {
        set_task(0.01, "force_duck", id)
        fm_set_entity_flags(id, FL_DUCKING, 1)
}

public force_duck(id) {
        fm_set_entity_flags(id, FL_DUCKING, 1)
}
__________________

Last edited by vato loco [GE-S]; 04-16-2009 at 11:32.
vato loco [GE-S] is offline
Lirix
Junior Member
Join Date: Nov 2008
Location: Russia
Old 04-16-2009 , 11:20   Re: checkpoints problem
Reply With Quote #3

what is '_fm_set_entity_flags'?
I can't compile it.
error: undefined symbol "_fm_set_entity_flags"
Lirix is offline
vato loco [GE-S]
Veteran Member
Join Date: Oct 2006
Location: Germany
Old 04-16-2009 , 11:25   Re: checkpoints problem
Reply With Quote #4

oh sorry i have forget to post the #define or stock for the fm stuff !!!
try this... this will work with engine
Code:
public goto_cp(id,cp) {
    new semiclip = get_pcvar_num(kz_semiclip)
    if(semiclip == -1 || (!noblock[id-1] && semiclip == 0)) {
        new Float:origin[3]
        for(new i=1;i<=get_maxplayers();i++) {
            if(id != i && is_user_connected(i) && is_user_alive(id)) {
                if(semiclip == -1 || (!noblock[i-1] && semiclip == 0)) {
                    entity_get_vector(i,EV_VEC_origin,origin)
                    if(get_distance_f(checkpoints[id-1][cp],origin) <= CP_DISTANCE) {
                        client_print(id,print_chat,"[KG Jump] Somebody is too close to your checkpoint")
                        return false
                    }
                }
            }
        }
    }
    delay_duck(id)
    entity_set_origin(id,checkpoints[id-1][cp])
    entity_set_vector(id,EV_VEC_velocity,Float:{0.0,0.0,0.0})
    spawnsprite(checkpoints[id-1][cp])
    set_user_gravity(id) // to fix the low gravity bug on kz_man_redrock (thanks to NoEx)
    noblock_task()
    
    return true
}
delay_duck(id) {
        set_task(0.01, "force_duck", id)
        set_entity_flags(id, FL_DUCKING, 1)
}

public force_duck(id) {
        set_entity_flags(id, FL_DUCKING, 1)
}
__________________

Last edited by vato loco [GE-S]; 04-16-2009 at 11:37.
vato loco [GE-S] is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-16-2009 , 11:29   Re: checkpoints problem
Reply With Quote #5

This is a poor way to make the player duck.
You can do what's following :

PHP Code:
SetUserOrigin_Safe(idFloat:flOrigin[3])
{
    
entity_set_origin(idflOrigin)
    
entity_set_int(idEV_INT_flagsentity_get_int(idEV_INT_flags) | FL_DUCKING)
    
call_think(id)

Or better IMO :
PHP Code:
new const Float:VEC_DUCK_HULL_MIN[3]    = {-16.0, -16.0, -18.0 }
new const 
Float:VEC_DUCK_HULL_MAX[3]    = { 16.0,  16.0,  18.0 }

SetUserOrigin_Safe(idFloat:flOrigin[3])
{
    
engfunc(EngFunc_SetSizeidVEC_DUCK_HULL_MINVEC_DUCK_HULL_MAX)
    
engfunc(EngFunc_SetOriginidflOrigin)

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Lirix
Junior Member
Join Date: Nov 2008
Location: Russia
Old 04-16-2009 , 13:21   Re: checkpoints problem
Reply With Quote #6

very big thanks.
Lirix 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 02:26.


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