Raised This Month: $51 Target: $400
 12% 

Unstuck help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PredatorBlock
AlliedModders Donor
Join Date: Apr 2020
Old 11-01-2020 , 16:24   Unstuck help
Reply With Quote #1

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.

Last edited by PredatorBlock; 11-01-2020 at 16:42.
PredatorBlock is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 11-02-2020 , 08:44   Re: Unstuck help
Reply With Quote #2

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

Last edited by Napoleon_be; 11-02-2020 at 08:49.
Napoleon_be is online now
Send a message via Skype™ to Napoleon_be
PredatorBlock
AlliedModders Donor
Join Date: Apr 2020
Old 11-03-2020 , 08:55   Re: Unstuck help
Reply With Quote #3

Quote:
Originally Posted by Napoleon_be View Post
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


Last edited by PredatorBlock; 11-03-2020 at 09:25.
PredatorBlock is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 11-03-2020 , 09:15   Re: Unstuck help
Reply With Quote #4

Can you post the full code?
__________________
Napoleon_be is online now
Send a message via Skype™ to Napoleon_be
PredatorBlock
AlliedModders Donor
Join Date: Apr 2020
Old 11-03-2020 , 16:46   Re: Unstuck help
Reply With Quote #5

Quote:
Originally Posted by Napoleon_be View Post
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; }

Last edited by PredatorBlock; 11-03-2020 at 16:49.
PredatorBlock is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 11-03-2020 , 16:56   Re: Unstuck help
Reply With Quote #6

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.
__________________
Napoleon_be is online now
Send a message via Skype™ to Napoleon_be
PredatorBlock
AlliedModders Donor
Join Date: Apr 2020
Old 11-07-2020 , 10:01   Re: Unstuck help
Reply With Quote #7

Quote:
Originally Posted by Napoleon_be View Post
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.

Last edited by PredatorBlock; 11-07-2020 at 10:03.
PredatorBlock 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 12:25.


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