Execute command from a menu
Hello! So i'm currently in the proccess of writing my very first SourceMod plugin. A VIP plguin (Menu & Commands) for my community. Though i am having some problems when trying to execute commands.
I have gotten so far so if the player writes the commands (!vipheal) or uses the menu and selects that option it prints in the chat "Fullt HP" (Swedish for full hp) BUT it does not give them full HP. I have searched all through the web and tried many different things but i can't seem to get it to work. Any help would be appreciated! if they use the menu. NOTE: It does print "Fullt HP" in the chat for that player. SO that part if working. Code:
case 2: Code:
public Action:Cmd_vipHeal(int client, int args) |
Re: Execute command from a menu
first things first i can't recommend mixing the two syntaxes, it looks bad and inconsistent as well as people on this forum will cry for weeks on end
continuing on - the blow example is wrong, followed by the correct method: %s is used for strings and/or char arrays, you'll want %i or %d for integers, or alternatively %N for the client's name (only if passing a client index, this is sourcemod specific), however none of these are recommended at all PHP Code:
just to clarify, clients are edicts, which are entities |
Re: Execute command from a menu
Thanks so much for the fast response!
First of all, about the using both ServerCommand() and PrintToServer() That is me just testing if anything works, ofcourse i will NOT use both when it gets to it, but thanks for pointing it out! :) Secondly, is the error that i'm using "%s"? When i use a command in-game i get an error in the console: "Tried to look up command say as if it were a variable." if that's related (ofcourse it is somehow but i don't know if it's the problem) Secondly. The set_entity_health. Yeah that might work, thought i also have an option to respawn and set gravity where i also want to use the sm_gravity / sm_respawn commands. How would i go about it there? Is it still the "%s" usage that is the problem and what i should use then? Thanks again for the answer :) |
Re: Execute command from a menu
I tried the
SetEntityHealth(client, 100); And that worked fine. So thanks! :) I still have my problem for the Revive and gravity. Any clues? |
Re: Execute command from a menu
https://sm.alliedmods.net/new-api/en...tEntityGravity
depending on your game: cstrike/csgo https://sm.alliedmods.net/new-api/cs..._RespawnPlayer tf2 https://sm.alliedmods.net/new-api/tf2/TF2_RespawnPlayer |
Re: Execute command from a menu
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:
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:oops: |
Re: Execute command from a menu
...why you change player admin bits? Not make sense.
*edit Ok, I maybe figure it out. You want bypass admin commands... |
Re: Execute command from a menu
Quote:
|
Re: Execute command from a menu
DON'T EVER DO THIS!
Quote:
|
Re: Execute command from a menu
Quote:
I also ever not notice this problem though I have never use servercommand for client.I learned,thanks for your answer! |
All times are GMT -4. The time now is 23:45. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.