Raised This Month: $ Target: $400
 0% 

Simple script


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nasta
Junior Member
Join Date: Jan 2006
Location: Malmö, Sweden
Old 01-13-2006 , 12:02   Simple script
Reply With Quote #1

I want to do a script of a config file, simply, when you say something like "/warmup" then commands like "rcon mp_startmoney 16000" is executed in the console. Instead of typing "warmup" in console. I just want an example so i can develop
nasta is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 01-13-2006 , 12:43  
Reply With Quote #2

Code:
#include <amxmodx> #include <amxmisc> public plugin_init() {   register_plugin("zomg h4x", "0.1", "teh pwn");   register_clcmd("say /warmup", "say_warmup", ADMIN_KICK); } public say_warmup(id, lvl, cid) {   if(!cmd_access(id, lvl, cid, 2)) {     return PLUGIN_HANDLED;   set_cvar_num("mp_startmoney", 16000);   client_print(0, print_chat, "zomg warmup started - gaben");   return PLUGIN_HANDLED; // return PLUGIN_CONTINUE if you want the chat message to be visible to everyone }
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
nasta
Junior Member
Join Date: Jan 2006
Location: Malmö, Sweden
Old 01-13-2006 , 12:48  
Reply With Quote #3

Quote:
Originally Posted by v3x
Code:
#include <amxmodx> #include <amxmisc> public plugin_init() {   register_plugin("zomg h4x", "0.1", "teh pwn");   register_clcmd("say /warmup", "say_warmup", ADMIN_KICK); } public say_warmup(id, lvl, cid) {   if(!cmd_access(id, lvl, cid, 2)) {     return PLUGIN_HANDLED;   set_cvar_num("mp_startmoney", 16000);   client_print(0, print_chat, "zomg warmup started - gaben");   return PLUGIN_HANDLED; // return PLUGIN_CONTINUE if you want the chat message to be visible to everyone }
Thanks! But how do i do when im putting in more than one command?

like

Code:
  set_cvar_num("mp_startmoney", 16000);   set_cvar_num("mp_startmoney2", 16000);
nasta is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 01-13-2006 , 12:50  
Reply With Quote #4

Code:
#include <amxmodx> #include <amxmisc> public plugin_init() {   register_plugin("zomg h4x", "0.1", "teh pwn");   register_clcmd("say /warmup", "say_warmup", ADMIN_KICK); } public say_warmup(id, lvl, cid) {   if(!cmd_access(id, lvl, cid, 2)) {     return PLUGIN_HANDLED;   set_cvar_num("mp_startmoney", 16000);   set_cvar_num("mp_friendlyfire", 0);   set_cvar_num("mp_gaben", 1);   // etc   client_print(0, print_chat, "zomg warmup started - gaben");   return PLUGIN_HANDLED; // return PLUGIN_CONTINUE if you want the chat message to be visible to everyone }
;)
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
nasta
Junior Member
Join Date: Jan 2006
Location: Malmö, Sweden
Old 01-13-2006 , 13:26  
Reply With Quote #5

Oh.. thanks!

Now i can do the things ive always dreamed of! -not-
But this is good enough for me


Just one another thing... When im creating another command to say, is it like this?

Code:
 #include <amxmodx> #include <amxmisc> public plugin_init() {   register_plugin("zomg h4x", "0.1", "teh pwn");   register_clcmd("say /warmup", "say_warmup", ADMIN_KICK);   register_clcmd("say /pcw", "say_pcw", ADMIN_KICK); } public say_warmup(id, lvl, cid) {   if(!cmd_access(id, lvl, cid, 2)) {     return PLUGIN_HANDLED;   set_cvar_num("mp_startmoney", 16000);   set_cvar_num("mp_friendlyfire", 0);   set_cvar_num("mp_gaben", 1);   // etc   client_print(0, print_chat, "zomg warmup started - gaben");   return PLUGIN_HANDLED; // return PLUGIN_CONTINUE if you want the chat message to be visible to everyone public say_pcw(id, lvl, cid) {   if(!cmd_access(id, lvl, cid, 2)) {     return PLUGIN_HANDLED;   set_cvar_num("mp_startmoney", 16000);   set_cvar_num("mp_friendlyfire", 0);   set_cvar_num("mp_gaben", 1);   // etc   client_print(0, print_chat, "zomg pcw started - gaben");   return PLUGIN_HANDLED; }

And i just need an explanation what the code snippets does...

Code:
 #include <amxmodx> #include <amxmisc> public plugin_init() {   register_plugin("zomg h4x", "0.1", "teh pwn");  // This is what the plugin's name is, but what does "0.1" stand for?   register_clcmd("say /warmup", "say_warmup", ADMIN_KICK);  //ADMIN_KICK? So everybody that can use the kick command can use this? } public say_warmup(id, lvl, cid) {   if(!cmd_access(id, lvl, cid, 2)) {     return PLUGIN_HANDLED; //Nothing i have to change here?   set_cvar_num("mp_startmoney", 16000);   set_cvar_num("mp_friendlyfire", 0);   set_cvar_num("mp_gaben", 1);   // etc   client_print(0, print_chat, "zomg warmup started - gaben");   return PLUGIN_HANDLED; }
nasta is offline
Wolle
Member
Join Date: Jun 2005
Location: Berlin / Germany
Old 01-13-2006 , 13:43  
Reply With Quote #6

A1)
0.1 stands for the plugin version.
It's just a build # you give to your plugin.
I usually begin with 1.0. When I change something within the code I also update the build # to 1.1 then 1.2 and so on.
This gives people, that use your plugin, an idea of what version of your plugin they use.

A2)
Exactly. Only admins that have "ADMIN_KICK" access can acces that function. In other words. You need at least "ADMIN_KICK" abilities in order to issue that command.

A3)
vex commented "return PLUGIN_CONTINUE if you want the chat message to be visible to everyone".
In case you want that you would also need to change that line.
Wolle is offline
Send a message via AIM to Wolle
nasta
Junior Member
Join Date: Jan 2006
Location: Malmö, Sweden
Old 01-13-2006 , 13:48  
Reply With Quote #7

Quote:
Originally Posted by Wolle
A1)
0.1 stands for the plugin version.
It's just a build # you give to your plugin.
I usually begin with 1.0. When I change something within the code I also update the build # to 1.1 then 1.2 and so on.
This gives people, that use your plugin, an idea of what version of your plugin they use.

A2)
Exactly. Only admins that have "ADMIN_KICK" access can acces that function. In other words. You need at least "ADMIN_KICK" abilities in order to issue that command.

A3)
vex commented "return PLUGIN_CONTINUE if you want the chat message to be visible to everyone".
In case you want that you would also need to change that line.
Yeah.. but, i meant the three lines above my comment thing
nasta is offline
Wolle
Member
Join Date: Jun 2005
Location: Berlin / Germany
Old 01-13-2006 , 13:58  
Reply With Quote #8

Are you talking about these 3 lines?
Code:
#include <amxmodx> #include <amxmisc> public plugin_init() {
Wolle is offline
Send a message via AIM to Wolle
nasta
Junior Member
Join Date: Jan 2006
Location: Malmö, Sweden
Old 01-13-2006 , 14:08  
Reply With Quote #9

Quote:
Originally Posted by Wolle
Are you talking about these 3 lines?
Code:
#include <amxmodx> #include <amxmisc> public plugin_init() {
No, sorry for my bad english...
Code:
public say_warmup(id, lvl, cid) {   if(!cmd_access(id, lvl, cid, 2)) {     return PLUGIN_HANDLED;
THAT!
nasta is offline
Wolle
Member
Join Date: Jun 2005
Location: Berlin / Germany
Old 01-13-2006 , 14:17  
Reply With Quote #10

Code:
say_warmup(id, lvl, cid)
Is the function's name and parameter list.
Since it needs to be public you prefix it with "public" like so.
Code:
public say_warmup(id, lvl, cid)

The next 2 lines just check if the user issuing the command got that "ADMIN_KICK" access. (this "!" means "NOT")
Code:
if(!cmd_access(id, lvl, cid, 2))
then just do nothing
Code:
return PLUGIN_HANDLED;
Wolle is offline
Send a message via AIM to Wolle
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 00:25.


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