AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Unstuck help (https://forums.alliedmods.net/showthread.php?t=328243)

PredatorBlock 11-01-2020 16:24

Unstuck help
 
Hello everyone.

Can someone help me with this.

I have a plugin which allow same team players to pass trough each other so in this way avoid blocking.
They can pass trough each other only if press key E and is hold.

Ok now i have into another plugin Unstuck option! what i am trying to do is to block execute the Unstuck code if key E is pressed ... i try with this but does not work!

Code:
stock is_player_stuck(id) { // Check if a player is stuck     if(!is_user_alive(id)) return false;     static Float:originF[3]; pev(id, pev_origin, originF)     engfunc(EngFunc_TraceHull, originF, originF, 0, (pev(id, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN, id, 0)         if(get_tr2(0, TR_StartSolid) || get_tr2(0, TR_AllSolid) || !get_tr2(0, TR_InOpen))         return true;         return false; } public Auto_Unstuck(taskid) {     new id = taskid - TASK_AUTO_UNSTUCK     new button = get_user_button(id)         // Check if key E is pressed     if((button & IN_USE))         return         if(g_isalive[id] && is_player_stuck(id) && get_pcvar_num(cvar_autounstuck))     {         // Check if player is stuck         ExecuteForward(g_forwards[UNSTUCK_PRE], g_fwDummyResult, id);         if(g_fwDummyResult >= PLUGIN_HANDLED) // The game mode didn't accept some conditions             return;         // Move to an initial spawn         if(get_pcvar_num(cvar_randspawn))             do_random_spawn(id) // random spawn (including CSDM)         else             do_random_spawn(id, 1) // regular spawn                 client_print(id, print_chat, "You should be un-stucked now!")     } }

I don't understand why the code after // Check if key E is pressed ..... is still executed?

Thank you.

Napoleon_be 11-02-2020 08:44

Re: Unstuck help
 
I'm not very experienced with this kind of stuff, but what if you just place that check inside this check
PHP Code:

if(g_isalive[id] && is_player_stuck(id) && get_pcvar_num(cvar_autounstuck)) 

and check if it's NOT pressed instead of it is pressed. That way you don't even need to use the return.

i think it should look something like this, i might be wrong though.
PHP Code:

if(g_isalive[id] && is_player_stuck(id) && get_pcvar_num(cvar_autounstuck) && (button &~ IN_USE)) 

or this

PHP Code:

if(g_isalive[id] && is_player_stuck(id) && get_pcvar_num(cvar_autounstuck) && !(button IN_USE)) 


PredatorBlock 11-03-2020 08:55

Re: Unstuck help
 
Quote:

Originally Posted by Napoleon_be (Post 2723444)
I'm not very experienced with this kind of stuff, but what if you just place that check inside this check
PHP Code:

if(g_isalive[id] && is_player_stuck(id) && get_pcvar_num(cvar_autounstuck)) 

and check if it's NOT pressed instead of it is pressed. That way you don't even need to use the return.

i think it should look something like this, i might be wrong though.
PHP Code:

if(g_isalive[id] && is_player_stuck(id) && get_pcvar_num(cvar_autounstuck) && (button &~ IN_USE)) 

or this

PHP Code:

if(g_isalive[id] && is_player_stuck(id) && get_pcvar_num(cvar_autounstuck) && !(button IN_USE)) 


Thank you for reply.

I test it, and something is change.

It won't spawn (unstuck) me now! instead it will spawn (unstuck) the other player while I'm inside it and holding the key E.

P.S
I think the problem is that the task is created also for other player and it will check if is blocked! but as I'm stay through him while i press E the task it detects the key E is hold only for me! so other will think is STUCK!

Code:
public client_putinserver(id) {     if(!is_user_bot(id)) {         set_task(get_pcvar_float(cvar_autounstuck_time), "Auto_Unstuck", id+TASK_AUTO_UNSTUCK, _, _, "b") // Auto UnStuck Player     } }

Anyone have a solution?

Thank you

https://i.ibb.co/gwGj3hG/Untitled.jpg

Napoleon_be 11-03-2020 09:15

Re: Unstuck help
 
Can you post the full code?

PredatorBlock 11-03-2020 16:46

Re: Unstuck help
 
Quote:

Originally Posted by Napoleon_be (Post 2723573)
Can you post the full code?

Code:
public client_putinserver(id) { set_task(5.0, "Auto_Unstuck", id+2000, _, _, "b") } public Auto_Unstuck(taskid) {     new id = taskid - TASK_AUTO_UNSTUCK     new button = get_user_button(id)         if(g_isalive[id] && is_player_stuck(id) && !(button & IN_USE))     {         ExecuteForward(g_forwards[UNSTUCK_PRE], g_fwDummyResult, id);         if(g_fwDummyResult >= ZP_PLUGIN_HANDLED) // The game mode didn't accept some conditions             return         // Move to an initial spawn         do_random_spawn(id, 1) // regular spawn                 client_print(id, print_chat, "You should be un-stucked now!")     } } stock is_player_stuck(id) {     if(!is_user_alive(id)) return false;     static Float:originF[3]; pev(id, pev_origin, originF)     engfunc(EngFunc_TraceHull, originF, originF, 0, (pev(id, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN, id, 0)         if(get_tr2(0, TR_StartSolid) || get_tr2(0, TR_AllSolid) || !get_tr2(0, TR_InOpen))         return true;         return false; }

Napoleon_be 11-03-2020 16:56

Re: Unstuck help
 
1) Why are you repeating the task?

2)
PHP Code:

public Auto_Unstuck(id)
{
    
id -= TASK_AUTO_UNSTUCK
    
new button get_user_button(id

3) The following is a piece of code i used in an earlier plugin of mine, try reflecting and editing where nessecary.
PHP Code:

public CmdStart(idHandle) {
    if(
gMode == Mode_NoScope && is_user_alive(id) && get_user_weapon(id) == CSW_SCOUT) {
        static 
button
        button 
get_uc(HandleUC_Buttons)
        
        if (
button IN_ATTACK2) {
            
button &= ~IN_ATTACK2
        
}
        
        
set_uc(HandleUC_Buttonsbutton)
    }


Hope this helps you out.

PredatorBlock 11-07-2020 10:01

Re: Unstuck help
 
Quote:

Originally Posted by Napoleon_be (Post 2723630)
1) Why are you repeating the task?

2)
PHP Code:

public Auto_Unstuck(id)
{
    
id -= TASK_AUTO_UNSTUCK
    
new button get_user_button(id

3) The following is a piece of code i used in an earlier plugin of mine, try reflecting and editing where nessecary.
PHP Code:

public CmdStart(idHandle) {
    if(
gMode == Mode_NoScope && is_user_alive(id) && get_user_weapon(id) == CSW_SCOUT) {
        static 
button
        button 
get_uc(HandleUC_Buttons)
        
        if (
button IN_ATTACK2) {
            
button &= ~IN_ATTACK2
        
}
        
        
set_uc(HandleUC_Buttonsbutton)
    }


Hope this helps you out.

Sorry for delay, some troubles with network.

I repeat the task cause each 5 seconds will check if user is stuck.

It won't help me that code! what you gave me.

Cause as i say already task will verify every 5 seconds each user that are alive.

If myself I'm stay inside through a player and hold key E it will be applied only for me! so the other player who i am inside of while i press E it will think is stuck cause only me I'm holding key E.

I need some how a code that will do similar like this:

if (player1 hold key E and inside player2 || player2 hold key E and inside player1)
return

I don't know how to explain better, hope you got the point.


All times are GMT -4. The time now is 14:09.

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