AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   spawn event (https://forums.alliedmods.net/showthread.php?t=331683)

strikevz 04-01-2021 14:42

spawn event
 
hello, thanks for reading! ----I got this plugin made by OciXCrom (whom I thank so much) for variable movement speed, but I need to add some code to modify the custom set speed every single respawn (infinite round is sometimes used on the server). So far I've been using another plugin which automatically triggers the command every round, but I can't use it when I turn on respawn and infinite round.
I tried doing it myself but I don't really get how to stick to the respawn event... and how to set the variable

thank you in advance


Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <hamsandwich>

#tryinclude <cromchat>

#if !defined _cromchat_included
    #error "cromchat.inc" is missing in your "scripting/include" folder. Download it from: "https://amxx-bg.info/inc/"
#endif

#tryinclude <targetex>

#if !defined _targetex_included
    #error "targetex.inc" is missing in your "scripting/include" folder. Download it from: "https://forums.alliedmods.net/showthread.php?t=331010"
#endif

#define MAX_NAME_LENGTH 32

#if !defined MAX_PLAYERS
const MAX_PLAYERS = 32
#endif

const Float:SPEED_DEFAULT = -120.9

new Float:g_fSpeed[MAX_PLAYERS + 1] = { SPEED_DEFAULT, ... }

public plugin_init()
{
    register_plugin("Change Speed Command", "1.1", "OciXCrom")
    register_concmd("amx_speed", "Cmd_Speed", ADMIN_SLAY, "<player|group> <speed amount|reset>")
    RegisterHam(Ham_CS_Player_ResetMaxSpeed, "player", "OnResetMaxSpeed", 1)
}

public OnResetMaxSpeed(id)
{
    if(g_fSpeed[id] != SPEED_DEFAULT)
    {
        set_user_maxspeed(id, g_fSpeed[id])
    }
}

public client_putinserver(id)
{
    g_fSpeed[id] = SPEED_DEFAULT
}

public Cmd_Speed(id, iLevel, iCid)
{
    if(!cmd_access(id, iLevel, iCid, 3))
    {
        return PLUGIN_HANDLED
    }

    new szArg[MAX_NAME_LENGTH], szTarget[MAX_NAME_LENGTH]
    read_argv(1, szArg, charsmax(szArg))

    new iPlayers[MAX_PLAYERS], iPnum = cmd_targetex(id, szArg, iPlayers, szTarget, charsmax(szTarget), TARGETEX_OBEY_IMM_SINGLE)

    if(!iPnum)
    {
        return PLUGIN_HANDLED
    }

    new szName[MAX_NAME_LENGTH], szAmount[8]
    get_user_name(id, szName, charsmax(szName))
    read_argv(2, szAmount, charsmax(szAmount))

    if(equali(szAmount, "reset"))
    {
        for(new iPlayer, i; i < iPnum; i++)
        {
            iPlayer = iPlayers[i]

            g_fSpeed[iPlayer] = SPEED_DEFAULT
            ExecuteHamB(Ham_CS_Player_ResetMaxSpeed, iPlayer)
        }

        CC_LogMessage(0, _, "ADMIN &x03%s &x01reset speed for &x03%s", szName, szTarget)
    }
    else
    {
        for(new iPlayer, i; i < iPnum; i++)
        {
            iPlayer = iPlayers[i]

            g_fSpeed[iPlayer] = str_to_float(szAmount)
            OnResetMaxSpeed(iPlayer)
        }
       
        CC_LogMessage(0, _, "ADMIN &x03%s &x01set &x04%s speed &x01on &x03%s", szName, szAmount, szTarget)
    }

    return PLUGIN_HANDLED
}


strikevz 04-03-2021 15:41

Re: spawn event
 
up

JocAnis 04-06-2021 13:35

Re: spawn event
 
hello, but with that code, its calling OnResetMaxSpeed which is triggered for example when player change their weapon (or something like tha) so your request to activate their speed on new spawn must work with this code by OciXCrom

i have no idea why it doesnt work, maybe some other plugin is 'blocking' it ?
ps: const Float:SPEED_DEFAULT = -120.9 is really random number, maybe put it at 250.0 as real default player speed? :D


All times are GMT -4. The time now is 02:54.

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