AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   green chat/days menu/admin tag help! (https://forums.alliedmods.net/showthread.php?t=194405)

illusionalp 08-28-2012 01:23

green chat/days menu/admin tag help!
 
hey,
1- i would like to know how can i execute admin commands using a plugin
eg :
lets say that i want to make new command called amx_Shark this command will excute two other commands amx_gravity 100 amx_noclip @ct any thoughts how can i do such thing ? any help will be appreciated
2- i would like to know how can i add a simple tag before the user with flag that i choose lets say flag b if the user had it i want to add [admin] tag before his name any thoughts how can i do that?
3- making a menu just like the guns menu in jailbreak but i want to change the functions like if you choose 1 the gravity will be changed and stuff like that
that is it i guess :)
regards,

Liverwiz 08-28-2012 01:42

Re: Scripting Help
 
1. server_cmd(const szCommand[], any . . .)
2. You'll have to catch each say, grab what they said, then add it to a string of what you want it to say and print it through a "SayText" message or client_print(0, print_chat, szMessage)
3. http://forums.alliedmods.net/showthread.php?t=46364 good tut on menus.

illusionalp 08-28-2012 01:59

Re: Scripting Help
 
Quote:

Originally Posted by Liverwiz (Post 1784791)
1. server_cmd(const szCommand[], any . . .)
2. You'll have to catch each say, grab what they said, then add it to a string of what you want it to say and print it through a "SayText" message or client_print(0, print_chat, szMessage)
3. http://forums.alliedmods.net/showthread.php?t=46364 good tut on menus.

thanks for your reply mate
i can't understand what to do with the first,second answers i'm new to amxmodx scripting :)
if it is possible can you explain more ? , the third answer worked perfectly

Liverwiz 08-28-2012 10:57

Re: Scripting Help
 
server_cmd is a function in amxmdx.inc
const szCommand[] is the main parameter (its the command you want to execute inputted as a string)
, any . . . means you're able to put in variables to the previous string.
for example.....
Code:

server_cmd("amx_gravity %d", iGravityToSet)
That's going to take a little bit of experience to do. Its not a simple "Hello World" app. But here's a real simple way of doing it. (not exactly what you want, because i'm lazy and don't want to give you all the answers)
PHP Code:

#include <amxmodx>

#define PLUGIN "Echo"
#define VERSION "1.0"
#define AUTHOR "Liverwiz"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say""handleSay")    // hook say command to handleSay (say is chat in game -default 'y')
}

public 
handleSay(id)
{
    new 
szInput[192]        // 192 is maxlen of text in chat (factoid for you)
    
read_args(szInputcharsmax(szInput) )    // this grabs what the player said
    
remove_quotes(szInput)        // remove quotes so it doesn't get messy
    
    
new szOutput[200], szName[32]    // initialize all variables we're going to use
    
get_user_name(idszNamecharsmax(szName) )
    
        
// This puts the name and input into one string
        // preping to print....
    
formatex(szOutputcharsmax(szOutput), "%s said: %s"szNameszInput)
    
    
client_print(0print_chatszOutput)
    
    return 
PLUGIN_CONTINUE


You should note that the formatex, and consequently szOutput are not required. You can put that directly into the client_print. I only put it there as an example if you were going to go the "SayText" message route, you'll have to use that method.

I wrote a plugin that does soemthing of this nature (plus lots of other crap) its called Private Message. You'll find it in new plugin submissions. It'll give you an example of grabbing text, minipulating it, and printing it using SayText messages

illusionalp 08-28-2012 16:37

Re: Scripting Help
 
Quote:

Originally Posted by Liverwiz (Post 1785068)
server_cmd is a function in amxmdx.inc
const szCommand[] is the main parameter (its the command you want to execute inputted as a string)
, any . . . means you're able to put in variables to the previous string.
for example.....
Code:

server_cmd("amx_gravity %d", iGravityToSet)
That's going to take a little bit of experience to do. Its not a simple "Hello World" app. But here's a real simple way of doing it. (not exactly what you want, because i'm lazy and don't want to give you all the answers)
PHP Code:

#include <amxmodx>

#define PLUGIN "Echo"
#define VERSION "1.0"
#define AUTHOR "Liverwiz"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say""handleSay")    // hook say command to handleSay (say is chat in game -default 'y')
}

public 
handleSay(id)
{
    new 
szInput[192]        // 192 is maxlen of text in chat (factoid for you)
    
read_args(szInputcharsmax(szInput) )    // this grabs what the player said
    
remove_quotes(szInput)        // remove quotes so it doesn't get messy
    
    
new szOutput[200], szName[32]    // initialize all variables we're going to use
    
get_user_name(idszNamecharsmax(szName) )
    
        
// This puts the name and input into one string
        // preping to print....
    
formatex(szOutputcharsmax(szOutput), "%s said: %s"szNameszInput)
    
    
client_print(0print_chatszOutput)
    
    return 
PLUGIN_CONTINUE


You should note that the formatex, and consequently szOutput are not required. You can put that directly into the client_print. I only put it there as an example if you were going to go the "SayText" message route, you'll have to use that method.

I wrote a plugin that does soemthing of this nature (plus lots of other crap) its called Private Message. You'll find it in new plugin submissions. It'll give you an example of grabbing text, minipulating it, and printing it using SayText messages

thanks for the reply again,

can you make a simple menu for me ? if yes then
1- change gravity to 30 and slap the username who executed it
2- change gravity to 70 and noclip @ct players
it will be appreciated , i need this menu to learn from it
how you did it , etc..
i will change the functions later
and about the chat plugin can you tell me how can i connect it to a flag like if i had flag x then i can have the [admin] tag before my name

fysiks 08-28-2012 19:05

Re: Scripting Help
 
Quote:

Originally Posted by illusionalp (Post 1784785)
2- i would like to know how can i add a simple tag before the user with flag that i choose lets say flag b if the user had it i want to add [admin] tag before his name any thoughts how can i do that?

There are plugins that do this already.

Liverwiz 08-28-2012 23:12

Re: Scripting Help
 
go to the request section. I gave you one plugin already....and i'm lazy tonight.

Or just go reading codes that are already written. Pleanty of examples out there. Also look around the tuts and code snippets section. Lots of good stuff there too.

illusionalp 08-28-2012 23:31

Re: Scripting Help
 
Quote:

Originally Posted by fysiks (Post 1785522)
There are plugins that do this already.

Quote:

Originally Posted by Liverwiz (Post 1785705)
go to the request section. I gave you one plugin already....and i'm lazy tonight.

Or just go reading codes that are already written. Pleanty of examples out there. Also look around the tuts and code snippets section. Lots of good stuff there too.


can you provide links ?

Liverwiz 08-28-2012 23:38

Re: Scripting Help
 
http://forums.alliedmods.net/forumdi...to_forumsearch
http://forums.alliedmods.net/forumdisplay.php?f=83
http://forums.alliedmods.net/forumdi...to_forumsearch
http://forums.alliedmods.net/forumdi...to_forumsearch

Hope that's enough....

illusionalp 08-29-2012 00:21

Re: Scripting Help
 
mate i was looking forward for a links to the threads


All times are GMT -4. The time now is 05:42.

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