AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   command for purchase only adm (https://forums.alliedmods.net/showthread.php?t=187885)

klysman07 06-19-2012 10:46

command for purchase only adm
 
I need a command to be placed in a case.

is a command that allows only Bus "b" can buy an item from the store

type: 500 for life (just adm)


thank you

Waleed 06-19-2012 11:36

Re: command for purchase only adm
 
Untested,But worked for me many time,Tell me if something is wrong,I just showed you what to do,It is not properly coded.Next time ask this in suggestion(i guess)

PHP Code:

register_clcmd("say /Check""cmd_Check"// register a clientcommand,i.e /Check or anyother

public cmd_Check(id)
{
      if(
is_user_admin(id// Only admin can use this;
{
      
//Put your code here,Everytime you type /Check in game,It will execute this code only for admins.
      // use cstrike and fun module for items and health and other stuff 



}



klysman07 06-19-2012 11:40

Re: command for purchase only adm
 
I would like to place a command in a shop.
and that item posssa only be purchased by ADM

type:

Quote:

case 1:
{
set_user_health(id, 500)

client_print( id, print_chat, "Voce comprou 500 de Vida!!")
client_print( id, print_chat, "By:Klysman =] !!")
client_cmd(id, "speak sound/GagaSong/Si.wav");
}

<VeCo> 06-19-2012 11:47

Re: command for purchase only adm
 
Check the user's access flag:
PHP Code:

if(get_user_flags(id) & ADMIN_RESERVATION// flag "b"
{
// ...



Waleed 06-19-2012 11:50

Re: command for purchase only adm
 
Use spk instead of speak,But if its working with "speak",Than you can use that;
PHP Code:

client_cmd(id"spk sound/GagaSong/Si.wav"); 

This checks that,If user is admin,The code or anything below that check will be executed only for admin,Don't need to define any flag for that(i think)

PHP Code:

if(is_user_admin(id))
{
   
//Anything here would be for admins only!
   //For example:

   
give_item(id"weapon_ak47"//Will give ak47 to admins only;
   
client_print(idprint_chat"You have been given ak47|Admin gift!"//This will print the message;
   


By the way,You will be needing fun module for "give_item"
Thanks;

klysman07 06-19-2012 11:51

Re: command for purchase only adm
 
Quote:

Originally Posted by <VeCo> (Post 1731707)
Check the user's access flag:
PHP Code:

if(get_user_flags(id) & ADMIN_RESERVATION// flag "b"
{
// ...





can you put the command ready to be placed please

I want to flag "b"

I place before or after?

set_user_health (id, 500)

Liverwiz 06-19-2012 11:52

Re: command for purchase only adm
 
Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #define PLUGIN "Crappy Plugin" #define VERSION "1.0" #define AUTHOR "CrapperCoder420" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_concmd("buy", "CrappyBuyFunction", ADMIN_BAN, "buy [item] [ammount]") } public CrappybuyFunction(id, level, cid) {     // This checks to see if the person who executed the command     // is in fact an admin, and passed 3 arguments into console     // 0 = command; 1 = item; 2 = ammount     // if not it simply returns out of the plugin and goes on with tis day     if(!cmd_access(id, level, cid, 3)         return PLUGIN_HANDLED             // This grabs the first argument from the command passed     // and saves it to the defined sz_item     new sz_item[32]; read_argv(1, sz_item, charsmax(sz_item) )     // This grabs the second argument from the command line     // and saves it to the defined sz_ammount string     new sz_ammount[32]; read_argv(2, sz_ammount, charsmax(sz_ammount) )     // I ignore the item because i odn't know really what you want to do     // I set sz_ammount to the ammount variable     // this is saved as an int/number/decimal using str_to_num     // which takes a string, parses it into a number, and returns it     new ammount = str_to_num(sz_ammount)     // I then return the ammount; Just to show it did something.     return ammount }

Aooka 06-19-2012 11:57

Re: command for purchase only adm
 
Try this :
Code:
#include < amxmodx > #include < fun > public plugin_init( ) {     register_plugin( "Test" , "1.0" , "Aooka" );         register_clcmd( "say /test" , "Cmd_Test" ); } public Cmd_Test( id ) {     if( is_user_alive( id ) )     {         if( get_user_flags( id ) & ADMIN_LEVEL_B )         {             set_user_health( id , 500 );             client_cmd( id , "spk sound/GagaSong/Si.wav" );                         client_print( id , print_chat , "Voce comprou 500 de Vida!!" );             client_print( id , print_chat , "By:Klysman =] !!" );         }         else         {             client_print( id , print_chat , "You must be an Admin with the flag B" );         }     } }

klysman07 06-19-2012 12:05

Re: command for purchase only adm
 
erro Aooka


Error: Undefined symbol "Add_Item" on line 31
Error: Undefined symbol "Add_Item" on line 32
Error: Undefined symbol "Add_Item" on line 33
Error: Undefined symbol "Add_Item" on line 34
Error: Undefined symbol "Add_Item" on line 35
Error: Undefined symbol "Add_Item" on line 36
Error: Undefined symbol "Add_Item" on line 39
Error: Undefined symbol "Add_Item" on line 40
Error: Undefined symbol "Add_Item" on line 41
Error: Undefined symbol "Add_Item" on line 42
Error: Undefined symbol "Add_Item" on line 43
Error: Undefined symbol "Add_Item" on line 44
Error: Undefined symbol "Add_Item" on line 45
Error: Undefined symbol "Add_Item" on line 46
Error: Undefined symbol "Add_Item" on line 47
Error: Undefined symbol "Add_Item" on line 48
Error: Undefined symbol "Add_Item" on line 49
Error: Undefined symbol "Add_Item" on line 50
Error: Undefined symbol "Add_Item" on line 51
Error: Undefined symbol "Add_Item" on line 52
Error: Undefined symbol "Add_Item" on line 53
Error: Undefined symbol "Add_Item" on line 54
Error: Undefined symbol "Add_Item" on line 55
Error: Undefined symbol "remove_colorMenu" on line 87
Error: Number of arguments does not match definition on line 87
Warning: Loose indentation on line 365
Error: Only a single statement (or expression) can follow each "case" on line 368

Compilation aborted.
26 Errors.

Quote:

case 1:
{
if( is_user_alive( id ) )
{
if( get_user_flags( id ) & ADMIN_LEVEL_B )
{

set_user_health(id, 500)

client_print( id, print_chat, "Voce comprou 500 de Vida!!")
client_print( id, print_chat, "By:Klysman =] !!")
client_cmd(id, "speak sound/GagaSong/Si.wav");
}

klysman07 06-19-2012 12:07

Re: command for purchase only adm
 
Warning: Loose indentation on line 357
Error: Only a single statement (or expression) can follow each "case" on line 365
Error: Empty statement on line 365
Warning: Symbol is never used: "g_iSet" on line 428

2 Errors.


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

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