This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

question to commands


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
inspire
Junior Member
Join Date: Aug 2010
Old 12-05-2011 , 12:07   question to commands
Reply With Quote #1

Code:
#pragma semicolon 2
#include <sourcemod>
#include <sdktools>
#include <cstrike>

public OnPluginStart()
{
RegServerCmd("sm_speed", CmdSpeed);
}


public Action:CmdSpeed(client, args)
{
    if (args < 2)
    {
        ReplyToCommand(client, "[SM] Usage: sm_speed <target> <multiplier>");
        return Plugin_Handled;    
    }    
    decl String:pattern[MAX_NAME],String:buffer[MAX_NAME],String:mul[MAX_ID];
    GetCmdArg(1,pattern,sizeof(pattern));
    GetCmdArg(2,mul,sizeof(mul));
    new Float:mult = StringToFloat(mul);
    new targets[MAX_CLIENTS],bool:ml = false;

    new count = ProcessTargetString(pattern,client,targets,sizeof(targets),FILTER_ALIVE,buffer,sizeof(buffer),ml);

    if (count <= 0) ReplyToCommand(client,"%t",(count < 0)?"Bad target":"No target",YELLOW,TEAMCOLOR,pattern,YELLOW);
    else for (new i = 0; i < count; i++)
    {
        new t = targets[i];
        SetEntPropFloat(t, Prop_Data, "m_flLaggedMovementValue", mult);
        if (g_bLog) LogAction(client,t,"\"%L\" set speed of player \"%L\" to %.1f",client,t,mult);
    }


    return Plugin_Handled;
}
Is this correct? and would "RegServerCmd("sm_speed", CmdSpeed);" make it able to use the sm_speed for other scripts..? where you just input "sm_speed target 2.0" or must i use RegConsoleCmd? AdminCmd? or any other?
inspire is offline
inspire
Junior Member
Join Date: Aug 2010
Old 02-14-2012 , 11:52   Re: question to commands
Reply With Quote #2

anyone?
inspire is offline
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 02-14-2012 , 12:28   Re: question to commands
Reply With Quote #3

RegServerCmd creates a command that can only be typed in the server console (or rcon). RegAdminCmd creates a command that requires a specific admin flag (and can also be executed from the server console/rcon). RegConsoleCmd creates a command that anyone can use (all clients and server/rcon). Chat triggers work for all except RegServerCmd.

Also, this is the syntax for RegServerCmd:

PHP Code:
public OnPluginStart() {
    
RegServerCmd("sm_dostuff"Command_DoStuff);
}

public 
Action:Command_DoStuff(args) { // notice it's not (client, args), rather just (args), since the client is always the server (which is 0)
    // do stuff here

__________________

Last edited by Dr. McKay; 02-14-2012 at 12:30.
Dr. McKay is offline
inspire
Junior Member
Join Date: Aug 2010
Old 02-15-2012 , 11:47   Re: question to commands
Reply With Quote #4

I have tried it with RegServerCmd("sm_speed", CmdSpeed);

in my thread above I already used the RegServerCmd.

But im trying to get the sm_speed to work as an new command, which you can input into another script, like for example est_speed, with eventscripts.

inspire is offline
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 02-15-2012 , 11:51   Re: question to commands
Reply With Quote #5

Quote:
Originally Posted by inspire View Post
I have tried it with RegServerCmd("sm_speed", CmdSpeed);

in my thread above I already used the RegServerCmd.

But im trying to get the sm_speed to work as an new command, which you can input into another script, like for example est_speed, with eventscripts.

That part's fine. Look closer at the callback.
__________________
Dr. McKay 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 04:43.


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