AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   [Req] Admin_Access (https://forums.alliedmods.net/showthread.php?t=318397)

VenomMix 08-29-2019 07:54

[Req] Admin_Access
 
Can you make these binds work only for admins with immunity?
eg. ADMIN_ACCESS ADMIN_IMMUNITY

HTML Code:

#include <amxmodx>
#include <engine>
#include <fakemeta>

new bool:is_sprinting[33] = false

public plugin_init() {
        register_plugin("Speed","1.3","Unknown")
        register_clcmd("+sprint","start_speed")
        register_clcmd("-sprint","end_speed")
}

public start_speed(id){
        is_sprinting[id] = true
        return PLUGIN_HANDLED;
}
public end_speed(id){
        is_sprinting[id] = false
        return PLUGIN_HANDLED;
}

public server_frame(){
        for(new i=0; i < get_maxplayers(); i++) {
                if(is_sprinting[i] == true){
                        set_speed(i);
                }
        }
}

public set_speed(id){
        if(!is_user_alive(id)) return PLUGIN_HANDLED;
        new Float:returnV[3], Float:Original[3]

        VelocityByAim ( id,600, returnV )
        pev(id,pev_velocity,Original)
        returnV[2] = Original[2]
       
        set_pev(id,pev_velocity,returnV)
        return PLUGIN_HANDLED;
}


thEsp 08-29-2019 07:57

Re: [Req] Admin_Access
 
Code:
// Next time use proper () tags to put the code on. #include <amxmodx> #include <engine> #include <fakemeta> new bool:is_sprinting[33] = false public plugin_init() {     register_plugin("Speed","1.3","Unknown")     register_clcmd("+sprint","start_speed")     register_clcmd("-sprint","end_speed") } public start_speed(id) if(get_user_flags(id) & ADMIN_IMMUNITY){     is_sprinting[id] = true     return PLUGIN_HANDLED; } public end_speed(id){     is_sprinting[id] = false     return PLUGIN_HANDLED; } public server_frame(){     for(new i=0; i < get_maxplayers(); i++) {         if(is_sprinting[i] == true){             set_speed(i);         }     } } public set_speed(id){     if(!is_user_alive(id)) return PLUGIN_HANDLED;     new Float:returnV[3], Float:Original[3]     VelocityByAim ( id,600, returnV )     pev(id,pev_velocity,Original)     returnV[2] = Original[2]         set_pev(id,pev_velocity,returnV)     return PLUGIN_HANDLED; }

edon1337 08-29-2019 08:12

Re: [Req] Admin_Access
 
Quote:

Originally Posted by thEsp (Post 2665187)
Code:
// Next time use proper () tags to put the code on. #include <amxmodx> #include <engine> #include <fakemeta> new bool:is_sprinting[33] = false public plugin_init() {     register_plugin("Speed","1.3","Unknown")     register_clcmd("+sprint","start_speed")     register_clcmd("-sprint","end_speed") } public start_speed(id) if(get_user_flags(id) & ADMIN_IMMUNITY){     is_sprinting[id] = true     return PLUGIN_HANDLED; } public end_speed(id){     is_sprinting[id] = false     return PLUGIN_HANDLED; } public server_frame(){     for(new i=0; i < get_maxplayers(); i++) {         if(is_sprinting[i] == true){             set_speed(i);         }     } } public set_speed(id){     if(!is_user_alive(id)) return PLUGIN_HANDLED;     new Float:returnV[3], Float:Original[3]     VelocityByAim ( id,600, returnV )     pev(id,pev_velocity,Original)     returnV[2] = Original[2]         set_pev(id,pev_velocity,returnV)     return PLUGIN_HANDLED; }

Use get_players() instead of looping from 1 to MaxPlayers, or at least cache get_maxplayers() into a global variable in plugin_init()

thEsp 08-29-2019 09:15

Re: [Req] Admin_Access
 
Quote the op, please.

VenomMix 08-30-2019 04:09

Re: [Req] Admin_Access
 
Work!

Natsheh 08-30-2019 05:28

Re: [Req] Admin_Access
 
Quote:

Originally Posted by thEsp (Post 2665200)
Quote the op, please.

to initial a start value for an array

You should do this
PHP Code:


new bool:is_sprinting[33] = {false, ...} 

INSTEAD OF
PHP Code:


new bool:is_sprinting[33] = false

I quoted you just to clarify you see this.

This is a common mistake alot of people fell into.


OP : also why are you using server_frame ?

You could use ham_deploy or any other forward that's called on weapon switch. It will be more efficient.

And also you should change maxspeed and not applying a velocity in the player direction that is aiming at, so if I'm aiming forward and moving right or left my sprinting will effect my movement.


All times are GMT -4. The time now is 10:56.

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