Raised This Month: $ Target: $400
 0% 

Making an admin set something on someone...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 02-26-2006 , 14:23   Making an admin set something on someone...
Reply With Quote #1

Hey, I was just wondering how I would get an admin to set gravity on a user...

This is what I have, but I get errors about the cmd_target and the !player, is_user_alive...
Code:
public admin_gravity(id) {     new name[32];     new player = cmd_target(id);     if (!player)     {         console_print(id,"[Purchase Mod]: %s does not exist.",name);         return PLUGIN_HANDLED;     }     get_user_name(player,name,31);     if (get_user_gravity(player) <= 200)     {         console_print(id,"[Purchase Mod]: %s already has gravity.",name);         return PLUGIN_HANDLED;     }     if (player,!is_user_alive)     {         console_print(id,"[Purchase Mod]: %s is not alive.",name);         return PLUGIN_HANDLED;     }     if (get_user_gravity(player) == 800)     {         set_user_gravity(player,0.25);         console_print(id,"[Purchase Mod]: %s has received low gravity.",name);         return PLUGIN_HANDLED;     }     return PLUGIN_HANDLED; }
__________________
My Plugins

Purchase Mod - Stable
Type Sounds - Stable
Monster Spawner - Stable
Nade Giver - Maintenance
Dizzy is offline
Send a message via AIM to Dizzy
Des12
Senior Member
Join Date: Jan 2005
Old 02-26-2006 , 16:24   Re: Making an admin set something on someone...
Reply With Quote #2

Code:
public admin_gravity(id) {     new name[32];     new player = cmd_target(id,player,4);         get_user_name(player,name,31);     if (!player)     {         console_print(id,"[Purchase Mod]: %s does not exist.",name);         return PLUGIN_HANDLED;     }         if (get_user_gravity(player) <= 200)     {         console_print(id,"[Purchase Mod]: %s already has gravity.",name);         return PLUGIN_HANDLED;     }     if (!is_user_alive(player))     {         console_print(id,"[Purchase Mod]: %s is not alive.",name);         return PLUGIN_HANDLED;     }     if (get_user_gravity(player) == 800)     {         set_user_gravity(player,0.25);         console_print(id,"[Purchase Mod]: %s has received low gravity.",name);         return PLUGIN_HANDLED;     }     return PLUGIN_HANDLED; }

Try that
__________________
-Dest Romano

www.JustRP.com
A TSRP Server

Quote:
Originally Posted by Brad
Don't you go be bringing reality into this.
Des12 is offline
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 02-26-2006 , 16:53  
Reply With Quote #3

Des12, I now get this,

Code:
//// purchasemod.sma
// C:\Program Files\Steam\SteamApps\[email protected]\dedicated server\cs
trike\addons\amxmodx\scripting\purchasemod.sma(394) : error 035: argument type m
ismatch (argument 2)
//
// 1 Error.
// Could not locate output file compiled\purchasemod.amx (compile failed).
//
// Compilation Time: 0.48 sec
What do you think now?
__________________
My Plugins

Purchase Mod - Stable
Type Sounds - Stable
Monster Spawner - Stable
Nade Giver - Maintenance
Dizzy is offline
Send a message via AIM to Dizzy
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 02-26-2006 , 17:00  
Reply With Quote #4

param #2 in cmd_target() should be a string, try this:

Code:
new arg[32], name[32]; read_argv(1, arg,31); new player = cmd_target(id,arg,4);
__________________
plop
p3tsin is offline
wouter
Senior Member
Join Date: Feb 2005
Location: Belgium
Old 02-26-2006 , 17:06  
Reply With Quote #5

there is allready such a pluging i think http://forums.alliedmods.net/showthread.php?p=19426
wouter is offline
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 02-26-2006 , 19:57  
Reply With Quote #6

Quote:
Originally Posted by wouter
there is allready such a pluging i think http://forums.alliedmods.net/showthread.php?p=19426
Do you even know what I'm doing?

Ok.. just wait...
__________________
My Plugins

Purchase Mod - Stable
Type Sounds - Stable
Monster Spawner - Stable
Nade Giver - Maintenance
Dizzy is offline
Send a message via AIM to Dizzy
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 02-26-2006 , 20:01  
Reply With Quote #7

Code:
 console_print(id,"[Purchase Mod]: %s does not exist.",name);

That will not return a name just to let you know.
You have new name[32] variable above the player check, and the get_user_name native below the player check making the variable useless at the top.

Make it this.

Code:
console_print(id,"[Purchase Mod]: Player does not exist.");

Also, doesn't the gravity need to be a float integer?
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
MaximusBrood
Veteran Member
Join Date: Sep 2005
Location: The Netherlands
Old 02-27-2006 , 13:47  
Reply With Quote #8

Dizzy, you have a quite strange problem...

Code:
public admin_gravity(id)

The var id contains the id of the admin who called the command.
But how does this function know who the target is?

Exactly... it doesn't

---

Solution: http://www.amxmodx.org/funcwiki.php?go=func&id=175
__________________
Released six formerly private plugins. Not active here since ages.
MaximusBrood is offline
Jordan
Veteran Member
Join Date: Aug 2005
Old 02-27-2006 , 18:09  
Reply With Quote #9

Code:
public admin_gravity(id, level, cid) {     new name[32];     new blahh;     new target = cmd_target(id, blahh, 4);     new Float:grav = get_user_gravity(target)             if(!cmd_access(id, level, cid, 2))     {         return PLUGIN_HANDLED;     }         get_user_name(target, name, 31);         if (!target)     {         console_print(id, "[Purchase Mod]: %s does not exist.", name);         return PLUGIN_HANDLED;     }       if(grav <= .25)     {         console_print(id, "[Purchase Mod]: %s already has gravity.", name);         return PLUGIN_HANDLED;     }         if(!is_user_alive(target))     {         console_print(id, "[Purchase Mod]: %s is not alive.", name);         return PLUGIN_HANDLED;     }         if(grav == 1.0)     {         set_user_gravity(target, 0.25);         console_print(id, "[Purchase Mod]: %s has received low gravity.", name);         return PLUGIN_HANDLED;     }     return PLUGIN_HANDLED; }

This should work. Btw, it's easier for people to help you if you show the entire code.
Jordan is offline
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 02-28-2006 , 00:24  
Reply With Quote #10

Quote:
Originally Posted by ^_^Satan^_^
This should work. Btw, it's easier for people to help you if you show the entire code.
Ok, I wanted to make it so that an admin could turn their powers on and off...

The 8 skills (Gravity, Speed, Stealth, Laser, Flash Glasses, Multijump, Bunnyhop, Health)

Code:
///////////////////////////// //AMXMOD[X]                // //Purchase Mod v1.1        // //By: Dizzy                // //(©)All rights reserved   // //                         // //Cvars:                   // //  amx_pmod (0|1) (off|on)// //                         // //Client Commands:         // //  pmodmenu               // ///////////////////////////// #include <amxmodx> #include <amxmisc> #include <cstrike> #include <engine> #include <fun> #define PLUGIN  "Purchase Mod" #define VERSION "1.1" #define AUTHOR  "Dizzy" #define DISPLAY_MSG #define FL_WATERJUMP    (1<<11) #define FL_ONGROUND (1<<9) new const itemcvar[8][] = {     "amx_pmod_gravitycost",     "amx_pmod_speedcost",     "amx_pmod_stealthcost",     "amx_pmod_lasercost",     "amx_pmod_flashglassescost",     "amx_pmod_multijumpcost",     "amx_pmod_bunnyhopcost",     "amx_pmod_healthcost" }; new const itemname[8][] = {     "gravity",     "speed",     "stealth",     "laser",     "flashglasses",     "multijump",     "bunnyhop",     "health" }; new powerpur[33] = 1; new powerpurgravity[33] = 1; new powerpurspeed[33] = 1; new powerpurstealth[33] = 1; new powerpurlaser[33] = 1; new powerpurflashglasses[33] = 1; new powerpurmultijump[33] = 1; new powerpurbunnyhop[33] = 1; new powerpurhealth[33] = 1; new jumpnum[33]; new bool:dojump[33]; new g_msgscreenfade; public client_connect(id) {     powerpur[id] = 1;     powerpurgravity[id] = 1;     powerpurspeed[id] = 1;     powerpurstealth[id] = 1;     powerpurlaser[id] = 1;     powerpurflashglasses[id] = 1;     powerpurmultijump[id] = 1;     powerpurbunnyhop[id] = 1;     powerpurhealth[id] = 1; } public client_disconnect(id) {     powerpur[id] = 1;     powerpurgravity[id] = 1;     powerpurspeed[id] = 1;     powerpurstealth[id] = 1;     powerpurlaser[id] = 1;     powerpurflashglasses[id] = 1;     powerpurmultijump[id] = 1;     powerpurbunnyhop[id] = 1;     powerpurflashglasses[id] = 1; } public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);     register_cvar("amx_pmod","1");     register_cvar(itemcvar[0],"3500");     register_cvar(itemcvar[1],"4000");     register_cvar(itemcvar[2],"5000");     register_cvar(itemcvar[3],"2000");     register_cvar(itemcvar[4],"5000");     register_cvar(itemcvar[5],"3000");     register_cvar(itemcvar[6],"6000");     register_cvar(itemcvar[7],"5000");     register_menucmd(register_menuid("Purchase Mod"), 1023, "menu");     register_clcmd("say pmodmenu","showMENU");     register_clcmd("say_team pmodmenu","showMENU");     register_concmd("pmodmenu","showMENU");     register_concmd("     register_event("ResetHUD","roundchange","b");     register_event("CurWeapon","speedb","be","1=1");     register_event("ScreenFade","event_blinded","be","4=255","5=255","6=255","7>199")     g_msgscreenfade = get_user_msgid("ScreenFade"); } ////////////////////// //      SOUNDS      // ////////////////////// public plugin_precache() {     precache_sound("purchasemod/buy.wav");     precache_sound("purchasemod/drain.wav");     precache_sound("purchasemod/sorry.wav"); } ////////////////////// //      INFORM      // ////////////////////// #if defined DISPLAY_MSG public client_putinserver(id) {     if (is_user_bot(id))         return;         set_task(25.0, "inform", id); } #endif #if defined DISPLAY_MSG public inform(id) {     client_print(id, print_chat, "[Purchase Mod]: This server is running Purchase Mod v1.1 -- By: Dizzy");     client_print(id, print_chat, "[Purchase Mod]: Type pmodmenu to start!");     return PLUGIN_HANDLED; } #endif ////////////////////// //    SHOWMENU      // ////////////////////// public showMENU(id) {     new menu[192];     new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8;     format(menu, 191, "Purchase Mod:^n^n1. Gravity ($3500)^n2. Speed ($4000)^n3. Stealth ($5000)^n4. Laser ($2000)^n5. Flash Glasses ($5000)^n6. Multi-Jump ($3000)^n7. Bunny Hop ($6000)^n8. Health ($5000)^n^n0. Exit");     show_menu(id,keys,menu);     return PLUGIN_HANDLED; } ////////////////////// //       MENU1      // ////////////////////// public menu(id, key) {     if(!get_cvar_num("amx_pmod"))     {         client_print(id, print_chat, "[Purchase Mod]: Sorry, the plugin is off!");         client_cmd(id,"spk purchasemod/sorry");         return PLUGIN_HANDLED;     }     if(!is_user_alive(id))     {         client_print(id, print_chat, "[Purchase Mod]: You must be alive to purchase this item!");         client_cmd(id,"spk purchasemod/sorry");         return PLUGIN_HANDLED;     }     if(powerpur[id] == 0)     {         client_print(id, print_chat, "[Purchase Mod]: You already purchased a different skill!");         client_cmd(id,"spk purchasemod/sorry");         return PLUGIN_HANDLED;     }     new money = cs_get_user_money(id);     new cost = get_cvar_num(itemcvar[key]);     if(cost > money)     {         client_print(id, print_chat, "[Purchase Mod]: You have insufficient funds!");         client_cmd(id,"spk purchasemod/sorry");         return PLUGIN_HANDLED;     }     cs_set_user_money(id, (money - cost), 1);     client_cmd(id,"spk purchasemod/buy");     client_print(id, print_chat, "[Purchase Mod]: You purchased %s for $%i!", itemname[key], cost);     switch(key)     {         case 0:         {             set_user_gravity(id, 0.25);             powerpurgravity[id] = 0;             powerpur[id] = 0;         }         case 1:         {             new Float:speed = get_user_maxspeed(id) + 680.0;             set_user_maxspeed(id, speed);             powerpurspeed[id] = 0;             powerpur[id] = 0;         }         case 2:         {             set_user_rendering(id, kRenderFxNone, 50, 50, 50, kRenderTransAdd, 50);             set_user_footsteps(id, 1);             powerpurstealth[id] = 0;             powerpur[id] = 0;         }         case 3:         {             set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 6.0, 10.0, 0.1, 0.1, 10);             show_hudmessage(id, "*");             set_task(5.0,"laser_loop",id);             powerpurlaser[id] = 0;             powerpur[id] = 0;         }         case 4:         {             set_task(0.0,"event_blinded",id)             powerpurflashglasses[id] = 0;             powerpur[id] = 0;         }         case 5:         {             powerpurmultijump[id] = 0;             powerpur[id] = 0;         }         case 6:         {             powerpurbunnyhop[id] = 0;             powerpur[id] = 0;         }         case 7:         {             set_user_health(id, get_user_health(id) + 50);             powerpurhealth[id] = 0;             powerpur[id] = 0;         }     }     return PLUGIN_HANDLED; } ////////////////////// //    PRETHINK      // ////////////////////// public client_PreThink(id) {     if(powerpurmultijump[id] == 0)     {         new nbut = get_user_button(id);         new obut = get_user_oldbutton(id);         if((nbut & IN_JUMP) && !(get_entity_flags(id) & FL_ONGROUND) && !(obut & IN_JUMP))         {             if(jumpnum[id] < 3)             {                 dojump[id] = true;                 jumpnum[id]++;                 return PLUGIN_CONTINUE;             }         }         if((nbut & IN_JUMP) && (get_entity_flags(id) & FL_ONGROUND))         {             jumpnum[id] = 0         }         return PLUGIN_CONTINUE;     }     if(powerpurbunnyhop[id] == 0)     {         entity_set_float(id, EV_FL_fuser2, 0.0);         if (entity_get_int(id, EV_INT_button) & 2)         {             new flags = entity_get_int(id, EV_INT_flags);             if (flags & FL_WATERJUMP)             {                 return PLUGIN_CONTINUE;             }             if (entity_get_int(id, EV_INT_waterlevel) >= 2)             {                 return PLUGIN_CONTINUE;             }             if(!(flags & FL_ONGROUND))             {                 return PLUGIN_CONTINUE;             }             new Float:velocity[3];             entity_get_vector(id, EV_VEC_velocity, velocity);             velocity[2] += 250.0;             entity_set_vector(id, EV_VEC_velocity, velocity);             entity_set_int(id, EV_INT_gaitsequence, 6);         }         return PLUGIN_CONTINUE;     }     return PLUGIN_HANDLED; } ////////////////////// //    POSTTHINK     // ////////////////////// public client_PostThink(id) {     if(dojump[id] == true && powerpurmultijump[id] == 0)     {         new Float:velocity[3];          entity_get_vector(id,EV_VEC_velocity,velocity);         velocity[2] = random_float(265.0,285.0);         entity_set_vector(id,EV_VEC_velocity,velocity);         dojump[id] = false;         return PLUGIN_CONTINUE;     }     return PLUGIN_CONTINUE; } ////////////////////// //      SPEEDB      // ////////////////////// public speedb(id) {     if(powerpurspeed[id] == 0)     {         new Float:speed = get_user_maxspeed(id) + 680.0;         set_user_maxspeed(id, speed);     }     return PLUGIN_HANDLED; } ////////////////////// //    LASER LOOP    // ////////////////////// public laser_loop(id) {     if(!is_user_alive(id))     {         return PLUGIN_HANDLED;     }     if(powerpurlaser[id] == 0)     {         set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 6.0, 10.0, 0.1, 0.1, 10);         show_hudmessage(id, "*");         set_task(0.0,"laser_loop",id);     }     return PLUGIN_HANDLED; } ////////////////////// //   FLASH EVENT    // ////////////////////// public event_blinded(id) {     if(powerpurflashglasses[id] == 0)     {         message_begin(MSG_ONE,g_msgscreenfade,{0,0,0},id);         write_short(~0);         write_short(10);         write_short(1<<12);         write_byte(0);         write_byte(0);         write_byte(0);         write_byte(100);         message_end();         set_task(0.0,"event_blinded",id)     }     if(powerpurflashglasses[id] == 1)     {         return PLUGIN_HANDLED;     }     return PLUGIN_HANDLED; } ////////////////////// //   ROUNDCHANGE    // ////////////////////// public roundchange(id) {     new arg[32], name[32];     read_argv(1, arg,31);     new player = cmd_target(id,arg,4);     get_user_name(player,name,31);     powerpur[id] = 1;     if(powerpurgravity[id] == 0)     {         set_user_gravity(id, 1.0);         client_cmd(id,"spk purchasemod/drain");         client_print(id, print_chat, "[Purchase Mod]: Gravity set back to normal!");         powerpurgravity[id] = 1;     }     if(powerpurspeed[id] == 0)     {         new Float:speed = get_user_maxspeed(id) - 680.0;         set_user_maxspeed(id,speed);         client_cmd(id,"spk purchasemod/drain");         client_print(id, print_chat, "[Purchase Mod]: Speed set back to normal!");         powerpurspeed[id] = 1;     }     if(powerpurstealth[id] == 0)     {         set_user_rendering(id,kRenderFxNone,255,255,255, kRenderNormal,16);         set_user_footsteps(id,0);         client_cmd(id,"spk purchasemod/drain");         client_print(id, print_chat, "[Purchase Mod]: Stealth level set back to normal!");         powerpurstealth[id] = 1;     }     if(powerpurlaser[id] == 0)     {         client_print(id, print_chat, "[Purchase Mod]: Laser bulb burnt out!");         client_cmd(id,"spk purchasemod/drain");         powerpurlaser[id] = 1;     }     if(powerpurflashglasses[id] == 0)     {         client_print(id, print_chat, "[Purchase Mod]: Your Flash Glasses broke!");         client_cmd(id,"spk purchasemod/drain");         powerpurflashglasses[id] = 1;     }     if(powerpurmultijump[id] == 0)     {         client_print(id, print_chat, "[Purchase Mod]: Multi-Jump ability ran out!");         client_cmd(id,"spk purchasemod/drain");         powerpurmultijump[id] = 1;     }     if(powerpurbunnyhop[id] == 0)     {         client_print(id, print_chat, "[Purchase Mod]: Bunny Hop ability ran out!");         client_cmd(id,"spk purchasemod/drain");         powerpurbunnyhop[id] = 1;     }     if(powerpurhealth[id] == 0)     {         client_cmd(id,"spk purchasemod/drain");         powerpurhealth[id] = 1;     }     return PLUGIN_HANDLED; }
__________________
My Plugins

Purchase Mod - Stable
Type Sounds - Stable
Monster Spawner - Stable
Nade Giver - Maintenance
Dizzy is offline
Send a message via AIM to Dizzy
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 20:27.


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