AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Can I call another plugins commands? (https://forums.alliedmods.net/showthread.php?t=10592)

KRiMoRaL 02-24-2005 01:49

Can I call another plugins commands?
 
I'm wondering if there is a way to call another plugins command from within a plugin i'm writing(trying to)

I currently have the plugins on the server that allow me to use amx_godmode, and amx_noclip..

What I'm trying to do is create a plugin that will allow me to do "amx_zeus <player>" and it will execute "amx_godmode <player> 1" on them. I don't want to call to the includes that use the functions like set_user_godmode(id,1) or whatever.. I specifically want to call to the commands offered by plugins already on the server.

Also, I know that there are probably other Zeus Plugins out there, but this is mostly for me to learn how to do and stuff.. that's why I'm doing it myself.

Here's kind of what I have: Which is just the basic outside

Code:
#include <amxmodx> #include <amxmisc> new PLUGIN[]="Zeus" new AUTHOR[]="KRiMoRaL" new VERSION[]="1.0" public plugin_init() {         register_plugin(PLUGIN, VERSION, AUTHOR)         register_concmd("amx_zeus", "cmd_zeus", ADMIN_LEVEL_A, " ")         register_concmd("amx_unzeus", "cmd_unzeus", ADMIN_LEVEL_A, " ") } cmd_zeus(id, level, cid) {     if (!cmd_access(id, level, cid, 3))             return PLUGIN_HANDLED               //I don't know how to call "amx_godmode <player> 1"     //I don't know how to call "amx_noclip <player> 1" } cmd_unzeus(id, level, cid) {     if (!cmd_access(id, level, cid, 3))         return PLUGIN_HANDLED     //Same as above, but to set to 0. }

XxAvalanchexX 02-24-2005 02:17

In your case, you can use the server_cmd function, which runs a server command.

Code:
new username[32]; get_user_name(id,username,31); server_cmd("amx_godmode ^"%s^" 1",username); server_cmd("amx_noclip ^"%s^" 1",username);

XunTric 02-24-2005 14:33

Try this.. I just copyed and pasted really fast from some of my other plugins. Not sure if it works... Remove the client_print if you want...
Code:
#include <amxmodx> #include <amxmisc> new PLUGIN[]="Zeus" new AUTHOR[]="KRiMoRaL" new VERSION[]="1.0" public plugin_init() {         register_plugin(PLUGIN, VERSION, AUTHOR)         register_concmd("amx_zeus", "cmd_zeus", ADMIN_LEVEL_A, "<name> Gives a player zeus mode")         register_concmd("amx_unzeus", "cmd_unzeus", ADMIN_LEVEL_A, "<name> Removes a players zeus mode") } public cmd_zeus(id, level, cid) {     if (!cmd_access(id,level,cid,2))          return PLUGIN_HANDLED     new arg[32]     read_argv(1,arg,31)     new player = cmd_target(id,arg,2)     if(!player)          return PLUGIN_HANDLED     new name[64];     get_user_name(player,name,63);    server_cmd(player, "amx_noclip %s 1")    server_cmd(player, "amx_godmode %s 1")    client_print(player, print_chat, "The Admin Gave You Zeus Mode")         return PLUGIN_HANDLED } public cmd_unzeus(id, level, cid) {     if (!cmd_access(id,level,cid,2))          return PLUGIN_HANDLED     new arg[32]     read_argv(1,arg,31)     new player = cmd_target(id,arg,2)     if(!player)          return PLUGIN_HANDLED     new name[64];     get_user_name(player,name,63);     server_cmd(player, "amx_noclip %s 0")     server_cmd(player, "amx_godmode %s 0")     client_print(player, print_chat, "The Admin Removed Your Zeus Mode")          return PLUGIN_HANDLED }

XxAvalanchexX 02-24-2005 15:04

XunTric, you can't just put %s and expect it to know what string you want it to replace it with, you have to specify that in the additional parameters.

XunTric 02-24-2005 15:09

Umm ok.. Btw avalanche, look at my other thread "Need help with a little NS script" hehe..

v3x 02-24-2005 15:10

Quote:

Originally Posted by XxAvalanchexX
XunTric, you can't just put %s and expect it to know what string you want it to replace it with, you have to specify that in the additional parameters.

:lol:

XunTric 02-24-2005 15:11

lol. " :lol: "? What was so funny about that? Im not that good at this lol.


All times are GMT -4. The time now is 14:17.

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