View Single Post
XiLuo
Member
Join Date: Mar 2018
Old 12-28-2018 , 23:13   Re: Execute command from a menu
Reply With Quote #6

If you want to use some commands on server like console command with 'sv_cheats 1'
Such as 'give health' , 'give ammo' and so on.
In l4d2 I usually use the function that is
PHP Code:
stock CheatCommand(clientString:command[], String:argument1[])
{
    new 
userFlags GetUserFlagBits(client);
    
SetUserFlagBits(clientADMFLAG_ROOT);
    new 
flags GetCommandFlags(command);
    
SetCommandFlags(commandflags & ~FCVAR_CHEAT);
    
FakeClientCommand(client"%s %s"commandargument1);
    
SetCommandFlags(commandflags);
    
SetUserFlagBits(clientuserFlags);

This function can execute command on 'sv_cheats 0'
For example,when you want to give 100 health to yourself you can invoke CheatCommand(client,"give health","100");
first argument is a client who will execute command,second and third arguments is the command and arg.
This code use the old grammar,you and update to new if you want.
For respawn and gravity,I also suggest use the method of sidezz.The API is so convenient and easily to use.
Hope to help you and Forgive me for my poor English,thanks

Last edited by XiLuo; 12-29-2018 at 00:04.
XiLuo is offline