Raised This Month: $ Target: $400
 0% 

How to make things carry over to the next round?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jordan
Veteran Member
Join Date: Aug 2005
Old 01-06-2006 , 16:44   How to make things carry over to the next round?
Reply With Quote #1

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <fun> #include <cstrike> new arg1[32] new arg2[10] public plugin_init() {     register_plugin("Personal Gravity", "1.1", "SatanWoJ")     register_concmd("amx_pgrav", "gravity", ADMIN_KICK, "<nick> <gravity>")     register_clcmd("say /buygrav", "bgrav", 0)     new keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_0     register_menucmd(register_menuid("Gravity Menu"), keys, "GravMenu") } public gravity(id, level, cid) {         if(!cmd_access(id, level, cid, 2))             return PLUGIN_HANDLED             read_argv(1, arg1, 31)         read_argv(2, arg2, 9)         new target = cmd_target(id, arg1, 15)         new Float:amount = str_to_float(arg2)/800         set_user_gravity(target, amount)         return PLUGIN_CONTINUE }     public bgrav(id) {         if(!is_user_alive(id))             return PLUGIN_HANDLED                     new menu[192]         new keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_0         format(menu, 191, "Gravity Menu^n^n1. 100 - $5000^n2. 200 - $3500^n3. 400 - $2000^n4. 550 - $1500^n5. 800 - $0^n^n0. BACK.")         show_menu(id, keys, menu)         return PLUGIN_HANDLED } public GravMenu(id, key) {     switch(key)     {         case 0:         {             new money = cs_get_user_money(id)             new Float:grav = get_user_gravity(id)             if(money < 5000)             {                 client_print(id, print_chat, "You have insufficient funds!")                 return PLUGIN_HANDLED             }             else if(grav == 0.125)                 {                     client_print(id, print_chat, "You already are at that gravity!")                     return PLUGIN_HANDLED                 }                 else                 {                         cs_set_user_money(id, money-5000)                         set_user_gravity(id, 0.125)                         return PLUGIN_HANDLED                 }         }         case 1:         {             new money = cs_get_user_money(id)             new Float:grav = get_user_gravity(id)             if(money < 3500)             {                 client_print(id, print_chat, "You have insufficient funds!")                 return PLUGIN_HANDLED             }             else if(grav == 0.25)                 {                     client_print(id, print_chat, "You already are at that gravity!")                     return PLUGIN_HANDLED                 } else {                         cs_set_user_money(id, money-3500)                         set_user_gravity(id, 0.25)                         return PLUGIN_HANDLED                 }         }         case 2:         {             new money = cs_get_user_money(id)             new Float:grav = get_user_gravity(id)             if(money < 2000)             {                 client_print(id, print_chat, "You have insufficient funds!")                 return PLUGIN_HANDLED             }             else if(grav == 0.5)                 {                     client_print(id, print_chat, "You already are at that gravity!")                     return PLUGIN_HANDLED                 } else {                         cs_set_user_money(id, money-2000)                         set_user_gravity(id, 0.5)                         return PLUGIN_HANDLED                 }         }         case 3:         {             new money = cs_get_user_money(id)             new Float:grav = get_user_gravity(id)             if(money < 1500)             {                 client_print(id, print_chat, "You have insufficient funds!")                 return PLUGIN_HANDLED             }             else if(grav == 0.6875)                 {                     client_print(id, print_chat, "You already are at that gravity!")                     return PLUGIN_HANDLED                 } else {                         cs_set_user_money(id, money-1500)                         set_user_gravity(id, 0.6875)                         return PLUGIN_HANDLED                 }         }         case 4:         {             new Float:grav = get_user_gravity(id)             if(grav == 1.0)                 {                     client_print(id, print_chat, "You already are at that gravity!")                     return PLUGIN_HANDLED                 } else {                         set_user_gravity(id, 1.0)                         return PLUGIN_HANDLED                 }         }         case 9:         {             return PLUGIN_HANDLED;         }     }     return PLUGIN_CONTINUE     }

I want to make it so that if a person selects their gravity and doesn't die, they get it next round... any way to do this?
Jordan is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 01-06-2006 , 17:02  
Reply With Quote #2

Make a float to store the gravity:
Code:
new Float:g_fGravity[33]; // Make sure you set it to 0.0 in client_connect!
Then use the Reset HUD event:
Code:
register_event("ResetHUD", "player_spawn", "b");
In the function hooked to the event:
Code:
public player_spawn( id ) {   if(g_fGravity[id] > 0.0)   {     set_user_gravity(id, g_fGravity[id]);   } }
Then in your gravity function:
Code:
public gravity(id, level, cid) {         if(!cmd_access(id, level, cid, 2))             return PLUGIN_HANDLED             read_argv(1, arg1, 31)         read_argv(2, arg2, 9)         new target = cmd_target(id, arg1, 15)         new Float:amount = str_to_float(arg2)/800         set_user_gravity(target, amount)         g_fGravity[id] = amount // set the amount         return PLUGIN_CONTINUE }
__________________
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
Jordan
Veteran Member
Join Date: Aug 2005
Old 01-06-2006 , 17:09  
Reply With Quote #3

Is reset_hud like the player spawning, b/c how will this know whether or not he lived?
Jordan is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 01-06-2006 , 19:13  
Reply With Quote #4

It can also be triggered by the console command fullupdate, as well as many other things.

It's exploitable, it's better to hook round time with register_logevent.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Des12
Senior Member
Join Date: Jan 2005
Old 01-06-2006 , 21:02  
Reply With Quote #5

to disable it if he dies, do
Code:
//in your plugin init register_event("DeathMsg","death_msg","a") //later on public death_msg(id) {      g_fGravity[id] = 0.0      return PLUGIN_HANDLED }
__________________
-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
Jordan
Veteran Member
Join Date: Aug 2005
Old 01-07-2006 , 12:14  
Reply With Quote #6

I still don't understand this -

Code:
new arg1[32] new arg2[10] new Float:g_fGravity[33]; new Float:g_fGravity2[33]; public plugin_init() {     register_plugin("Personal Gravity", "1.1", "SatanWoJ")     register_concmd("amx_pgrav", "gravity", ADMIN_KICK, "<nick> <gravity>")     register_clcmd("say /buygrav", "bgrav", 0)     new keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_0     register_menucmd(register_menuid("Gravity Menu"), keys, "GravMenu")     register_logevent("hook_roundstart", 2, "0=World triggered", "1=Round_Start");       register_event("ResetHUD", "player_spawn", "b");     register_event("DeathMsg", "hook_death", "d") } public client_connect(id) {     g_fGravity2[id] = 1.0 } public gravity(id, level, cid) {         if(!cmd_access(id, level, cid, 2))             return PLUGIN_HANDLED             read_argv(1, arg1, 31)         read_argv(2, arg2, 9)         new target = cmd_target(id, arg1, 15)         new Float:amount = str_to_float(arg2)/800         set_user_gravity(target, amount)         g_fGravity[id] = amount         return PLUGIN_CONTINUE }     public bgrav(id) {         if(!is_user_alive(id))             return PLUGIN_HANDLED                     new menu[192]         new keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_0         format(menu, 191, "Gravity Menu^n^n1. 100 - $5000^n2. 200 - $3500^n3. 400 - $2000^n4. 550 - $1500^n5. 800 - $0^n^n0. BACK.")         show_menu(id, keys, menu)         return PLUGIN_HANDLED } public GravMenu(id, key) {     switch(key)     {         case 0:         {             new money = cs_get_user_money(id)             new Float:grav = get_user_gravity(id)             if(money < 5000)             {                 client_print(id, print_chat, "You have insufficient funds!")                 return PLUGIN_HANDLED             }             else if(grav == 0.125)                 {                     client_print(id, print_chat, "You already are at that gravity!")                     return PLUGIN_HANDLED                 }                 else                 {                         cs_set_user_money(id, money-5000)                         set_user_gravity(id, 0.125)                         g_fGravity2[id] = 0.125                         return PLUGIN_HANDLED                 }         }         case 1:         {             new money = cs_get_user_money(id)             new Float:grav = get_user_gravity(id)             if(money < 3500)             {                 client_print(id, print_chat, "You have insufficient funds!")                 return PLUGIN_HANDLED             }             else if(grav == 0.25)                 {                     client_print(id, print_chat, "You already are at that gravity!")                     return PLUGIN_HANDLED                 } else {                         cs_set_user_money(id, money-3500)                         set_user_gravity(id, 0.25)                         g_fGravity2[id] = 0.25                         return PLUGIN_HANDLED                 }         }         case 2:         {             new money = cs_get_user_money(id)             new Float:grav = get_user_gravity(id)             if(money < 2000)             {                 client_print(id, print_chat, "You have insufficient funds!")                 return PLUGIN_HANDLED             }             else if(grav == 0.5)                 {                     client_print(id, print_chat, "You already are at that gravity!")                     return PLUGIN_HANDLED                 } else {                         cs_set_user_money(id, money-2000)                         set_user_gravity(id, 0.5)                         g_fGravity2[id] = 0.5                         return PLUGIN_HANDLED                 }         }         case 3:         {             new money = cs_get_user_money(id)             new Float:grav = get_user_gravity(id)             if(money < 1500)             {                 client_print(id, print_chat, "You have insufficient funds!")                 return PLUGIN_HANDLED             }             else if(grav == 0.6875)                 {                     client_print(id, print_chat, "You already are at that gravity!")                     return PLUGIN_HANDLED                 } else {                         cs_set_user_money(id, money-1500)                         set_user_gravity(id, 0.6875)                         g_fGravity2[id] = 0.6875                         return PLUGIN_HANDLED                 }         }         case 4:         {             new Float:grav = get_user_gravity(id)             if(grav == 1.0)                 {                     client_print(id, print_chat, "You already are at that gravity!")                     return PLUGIN_HANDLED                 } else {                         set_user_gravity(id, 1.0)                         g_fGravity2[id] = 1.0                         return PLUGIN_HANDLED                 }         }         case 9:         {             return PLUGIN_HANDLED;         }     }     return PLUGIN_CONTINUE     }     public hook_roundstart(id) {     if(g_fGravity[id] > 0.0)     {         set_user_gravity(id, g_fGravity[id]);         set_user_gravity(id, g_fGravity2[id]);     } }   public hook_death(id) {     new Killer = read_data(1)     new Victim = read_data(2)     g_fGravity[victim] = 1.0     g_fGravity2[victim] = 1.0     return PLUGIN_HANDLED }

I've tried just about everything, and if a person dies they don't get their gravity back (which is good). But, if a person lives, they don't get their gravity back either (which is bad). >.<
Jordan is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 01-07-2006 , 13:17  
Reply With Quote #7

Maybe because there is no function player_spawn in that?
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Jordan
Veteran Member
Join Date: Aug 2005
Old 01-07-2006 , 13:22  
Reply With Quote #8

Bah that's just extra - I replaced it with hook_roundstart - and I tried the player_spawn function too
Jordan is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 01-07-2006 , 13:23  
Reply With Quote #9

Code:
register_event("ResetHUD", "player_spawn", "b");

From my experiences, when you leave in code like that, which doesn't actually work, the entire plugin stops working. Comment that line then try again.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Reply


Thread Tools
Display Modes

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 16:07.


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