AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Not work player velocity (https://forums.alliedmods.net/showthread.php?t=221654)

kulers2010 07-24-2013 19:47

Not work player velocity
 
Thats my function
PHP Code:

public pfn_touch(entid)
{
    if (
id && id <= 32)
    {
        if (
is_user_alive(id))
        {
            if (
isBlock(ent))
            {
                new 
blockType entity_get_int(entEV_INT_body);                
                if (
blockType == BM_BHOP || blockType == BM_BARRIER_CT || blockType == BM_BARRIER_T || blockType == BM_BHOP_NOSLOW || blockType == BM_NONADMIN || blockType == BM_DELAYED)
                {
                    if (!
task_exists(TASK_BHOPSOLIDNOT ent) && !task_exists(TASK_BHOPSOLID ent))
                    {
                        new 
CsTeams:team cs_get_user_team(id);
                        
                        if (
blockType == BM_BARRIER_CT && team == CS_TEAM_T)
                        {
                            
taskSolidNot(TASK_BHOPSOLIDNOT ent);
                        }
                        else if (
blockType == BM_BARRIER_T && team == CS_TEAM_CT)
                        {
                            
taskSolidNot(TASK_BHOPSOLIDNOT ent);
                        }
                        else if (
blockType == BM_BHOP || blockType == BM_BHOP_NOSLOW)
                        {
                            
set_task(0.1"taskSolidNot"TASK_BHOPSOLIDNOT ent);
                        }
                        else if (
blockType == BM_NONADMIN && get_user_flags(id) & ADMIN_LEVEL_H)
                        {
                            
taskSolidNot(TASK_BHOPSOLIDNOT ent);
                        }
                        else if (
blockType == BM_DELAYED)
                        {
                            
set_task(2.0"taskSolidNot"TASK_BHOPSOLIDNOT ent);
                        }
                    }
                }else{
                    new 
FloatAngel[3];
                    
entity_get_vector(ent,EV_VEC_angles,Angel);
                    
//client_print(id,print_chat,"Angle: %f %f %f",Angel[0],Angel[1],Angel[2]);
                    
if(floatround(Angel[0]) == 90){
                        if(
blockType == BM_TRAMPOLINE)
                            
set_task(0.0,"actionTrampoline",id);
                        else if(
blockType == BM_LOWTRAMPOLINE)
                            
set_task(0.0,"actionLowTrampoline",id);
                        else if(
blockType == BM_HIGHTRAMPOLINE){
                            
set_task(0.0,"actionHighTrampoline",id);
                        }
                    }
                    
                    
                    
//Slide turas pie apaksas blokam
                    
if(blockType  ==  BM_SLIDE){
                        new 
Float:velocity[3];        
                        
entity_get_vector(idEV_VEC_velocityvelocity);
                        
velocity[2] = 100.0;                
                        
entity_set_vector(idEV_VEC_velocityvelocity);
                        
                        
client_print(id,print_chat,"Velocity 100");
                        
                    }
                    
                }
                
            }
        }
    }
    
    return 
PLUGIN_CONTINUE;


And thats not work, its only show in chat thats text velocity 100
PHP Code:

if(blockType  ==  BM_SLIDE){
                        new 
Float:velocity[3];        
                        
entity_get_vector(idEV_VEC_velocityvelocity);
                        
velocity[2] = 100.0;                
                        
entity_set_vector(idEV_VEC_velocityvelocity);
                        
                        
client_print(id,print_chat,"Velocity 100");
                        
                    } 


MPD 07-25-2013 05:45

Re: Not work player velocity
 
This was bothering me also. It turned out that it works for me only if I make set_task(0.1, ...). I have no idea what to do else to make velocity work.

kulers2010 07-25-2013 08:46

Re: Not work player velocity
 
Quote:

Originally Posted by MPD (Post 1998302)
This was bothering me also. It turned out that it works for me only if I make set_task(0.1, ...). I have no idea what to do else to make velocity work.

I wrote set_task(0.0,,, but i need immediately, not after it do task

YamiKaitou 07-25-2013 08:55

Re: Not work player velocity
 
The minimun time a task can execute is 0.1 seconds. So putting anything less than that assumes you mean 0.1. If you need it right away, then call the function directly

kulers2010 07-25-2013 16:17

Re: Not work player velocity
 
its not work

Black Rose 07-26-2013 10:55

Re: Not work player velocity
 
Quote:

Originally Posted by kulers2010 (Post 1998691)
its not work

What doesn't work?
What is supposed to happen? What does happen?

MPD 07-26-2013 11:12

Re: Not work player velocity
 
Quote:

Originally Posted by Black Rose (Post 1999151)
What doesn't work?
What is supposed to happen? What does happen?

Setting velocity right after you get velocity doesn't work.

Black Rose 07-26-2013 11:17

Re: Not work player velocity
 
Quote:

Originally Posted by MPD (Post 1999167)
Setting velocity right after you get velocity doesn't work.

I find this very hard to believe. Will try for myself.

EDIT: No problem at all...
When I set it at 100 instead of 1000 it won't move. When I use 200, it's almost like a normal jump. 100 is simply too low. Problem solved.
Code:
#include <amxmodx> #include <engine> public plugin_init() {     register_plugin("Test Plugin 9", "", "");     register_clcmd("megajump", "megajump"); } public megajump(id) {         new Float:velocity[3];         entity_get_vector(id, EV_VEC_velocity, velocity);     velocity[2] = 1000.0;     entity_set_vector(id, EV_VEC_velocity, velocity); }

MPD 07-26-2013 12:15

Re: Not work player velocity
 
Quote:

Originally Posted by Black Rose (Post 1999170)
I find this very hard to believe. Will try for myself.

EDIT: No problem at all...
When I set it at 100 instead of 1000 it won't move. When I use 200, it's almost like a normal jump. 100 is simply too low. Problem solved.
Code:
#include <amxmodx> #include <engine> public plugin_init() {     register_plugin("Test Plugin 9", "", "");     register_clcmd("megajump", "megajump"); } public megajump(id) {         new Float:velocity[3];         entity_get_vector(id, EV_VEC_velocity, velocity);     velocity[2] = 1000.0;     entity_set_vector(id, EV_VEC_velocity, velocity); }

With clcmd everything works fine, I've tested it earlier. This is not solution, because it didn't work correctly without clcmd.

I was searching for answer on the internet and found that you need to get velocity in
PHP Code:

public client_PreThink(id

and set velocity in
PHP Code:

public client_PostThink(id

Maybe it will help. I will test it as soon as I can.

Black Rose 07-26-2013 15:06

Re: Not work player velocity
 
Quote:

Originally Posted by MPD (Post 1999203)
With clcmd everything works fine, I've tested it earlier. This is not solution, because it didn't work correctly without clcmd.

I was searching for answer on the internet and found that you need to get velocity in
PHP Code:

public client_PreThink(id

and set velocity in
PHP Code:

public client_PostThink(id

Maybe it will help. I will test it as soon as I can.

This would be my best suggestion. Maybe it will need a loop to check for multiple players in need of a boost before unregister_forward() is called. I'm testing everything solo, so I can't determine.
Using Hamsandwich and Fakemeta is just a personal preference. Works just as well with engine.
Code:
#include <amxmodx> #include <hamsandwich> #include <fakemeta> new Float:g_pVelocity[33][3]; new g_fPostThink; public plugin_init() {     register_plugin("Test Plugin 9", "", "");         RegisterHam(Ham_Touch, "player", "HamTouch"); } public HamTouch(id, ent) {     if ( 0 < id < 33 ) {         pev(id, pev_velocity, g_pVelocity[id]);         g_pVelocity[id][2] = 100.0;         g_fPostThink = register_forward(FM_PlayerPostThink, "PlayerPostThink", 1);     } } public PlayerPostThink(id) {     if ( g_pVelocity[id][2] == 100.0 ) {         unregister_forward(FM_PlayerPostThink, g_fPostThink, 1);         set_pev(id, pev_velocity, g_pVelocity[id]);     } }


All times are GMT -4. The time now is 06:29.

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