Raised This Month: $51 Target: $400
 12% 

Solved help!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Grovliom
Member
Join Date: Mar 2020
Location: somewhere in Serbia
Old 06-10-2020 , 15:17   help!
Reply With Quote #1

i'm still making this mod, but it buys stamina for other players and i just want to buy for me! help please

Code:
new stamina new laser new nbut new Act public plugin_init() {     register_clcmd("say /stamina", "buyStam")     register_clcmd("say_team /stamina", "buyStam") } public buyStam(id) {     new menu = menu_create("Stamina Menu", "menu_handler")     menu_additem(menu, "+10 Stamina - 7000$ -", "", 0)     menu_additem(menu, "+5 Stamina - 4000$ -", "", 0)     menu_additem(menu, "+1 Stamina - 1000$ -", "", 0)     menu_setprop( menu, MPROP_EXIT, MEXIT_ALL );     menu_display(id, menu, 0) } public menu_handler(id, menu, item) {        switch( item )     {         case 0:             {                 if(cs_get_user_money(id) < 7000)                 {                     cs_set_user_money(id, cs_get_user_money(id))                     client_print(id, print_center, "You don't have enough money for that...")                     message_begin(MSG_ONE, get_user_msgid("ScreenFade"), "", id);                     write_short(1024);                     write_short(0);                     write_short(0);                     write_byte(255);                     write_byte(0);                     write_byte(0);                     write_byte(255);                     message_end();                                     }                 else                 {                     if(stamina == 10)                     {                         client_print(id, print_center, "-MAXIMUM STAMINA REACHED-")                         message_begin(MSG_ONE, get_user_msgid("ScreenFade"), "", id);                         write_short(1024);                         write_short(0);                         write_short(0);                         write_byte(255);                         write_byte(0);                         write_byte(0);                         write_byte(255);                         message_end();                     }                     else                     {                         stamina = stamina + 10                         client_print(id, print_center, "+10 Stamina")                         cs_set_user_money(id, cs_get_user_money(id) - 7000)                         menu_destroy( menu );                         return PLUGIN_HANDLED;                     }                 }             }         case 1:             {             if(cs_get_user_money(id) < 4000)                 {                     cs_set_user_money(id, cs_get_user_money(id))                     client_print(id, print_center, "You don't have enough money for that...")                     message_begin(MSG_ONE, get_user_msgid("ScreenFade"), "", id);                     write_short(1024);                     write_short(0);                     write_short(0);                     write_byte(255);                     write_byte(0);                     write_byte(0);                     write_byte(255);                     message_end();                                     }                 else                 {                     if(stamina == 10)                     {                         client_print(id, print_center, "-MAXIMUM STAMINA REACHED-")                         message_begin(MSG_ONE, get_user_msgid("ScreenFade"), "", id);                         write_short(1024);                         write_short(0);                         write_short(0);                         write_byte(255);                         write_byte(0);                         write_byte(0);                         write_byte(255);                         message_end();                     }                     else                     {                         stamina = stamina + 5                         client_print(id, print_center, "+5 Stamina")                         cs_set_user_money(id, cs_get_user_money(id) - 4000)                         menu_destroy( menu );                         return PLUGIN_HANDLED;                     }                 }             }         case 2:             {                 if(cs_get_user_money(id) < 1000)                 {                     cs_set_user_money(id, cs_get_user_money(id))                     client_print(id, print_center, "You don't have enough money for that...")                     message_begin(MSG_ONE, get_user_msgid("ScreenFade"), "", id);                     write_short(1024);                     write_short(0);                     write_short(0);                     write_byte(255);                     write_byte(0);                     write_byte(0);                     write_byte(255);                     message_end();                                     }                 else                 {                     if(stamina == 10)                     {                         client_print(id, print_center, "-MAXIMUM STAMINA REACHED-")                         message_begin(MSG_ONE, get_user_msgid("ScreenFade"), "", id);                         write_short(1024);                         write_short(0);                         write_short(0);                         write_byte(255);                         write_byte(0);                         write_byte(0);                         write_byte(255);                         message_end();                     }                     else                     {                         stamina = stamina + 1                         client_print(id, print_center, "+1 Stamina")                         cs_set_user_money(id, cs_get_user_money(id) - 1000)                         menu_destroy( menu );                         return PLUGIN_HANDLED;                     }                 }             }     }     menu_destroy( menu );     return PLUGIN_HANDLED; } public plugin_precache() {     laser = precache_model("sprites/laserbeam.spr")     precache_sound("ultramod/zap1.wav") } public client_putinserver(id) {     stamina = 0 } public client_PreThink(id) {        if(is_user_alive(id))     {     set_hudmessage(random(255), random(255), random(255), 0.29, 0.88, 0, 6.0, 0.1)     show_hudmessage(id, "Stamina:%d", stamina)         nbut = get_user_oldbutton(id)         new hit     new body         new origin[3], aimorigin[3]     get_user_origin(id,origin)     get_user_origin(id,aimorigin,3)         if(stamina < 0)         {             Act = 1         }     if(stamina > 10)         {             stamina = 10         }     if(Act == 1)         {             Act = 0             stamina = stamina + 1         }     if (nbut == IN_USE)     {         if(stamina == 0)         {                     }         if(stamina > 0)             {                 get_user_aiming(id, hit, body, 9999)                 set_user_health(hit, -1)                 remove_task(id)                 stamina = stamina - 1                 message_begin(MSG_ALL,SVC_TEMPENTITY)                 write_byte(0)         // TE_BEAMPOINTS                 write_coord(origin[0])    // start point                 write_coord(origin[1])                 write_coord(origin[2])                 write_coord(aimorigin[0])   // end point                 write_coord(aimorigin[1])                 write_coord(aimorigin[2])                 write_short(laser)    // sprite to draw (below)                 write_byte(0)         // starting frame                 write_byte(0)         // frame rate                 write_byte(1)         // life in 0.1s                 write_byte(3)         // line width in 0.1                 write_byte(0)         // noise in 0.1                 write_byte(random(255))  // R                 write_byte(random(255))  // G                 write_byte(random(255))  // B                 write_byte(200)   // brightness                 write_byte(2)         // scroll speed                 message_end()             }         }     } }

Last edited by Grovliom; 06-12-2020 at 10:59.
Grovliom is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-10-2020 , 18:29   Re: help!
Reply With Quote #2

These variables are shared between all players on the server.

new stamina
new nbut
new Act

All should be arrays to allow a variable for each individual player:
PHP Code:
#define MAX_PLAYERS 32

new staminaMAX_PLAYERS ]
new 
nbutMAX_PLAYERS ]
new 
ActMAX_PLAYERS ]

//Then use stamina[ id ] 
__________________

Last edited by Bugsy; 06-10-2020 at 18:31.
Bugsy is offline
Grovliom
Member
Join Date: Mar 2020
Location: somewhere in Serbia
Old 06-10-2020 , 18:39   Re: help!
Reply With Quote #3

Quote:
Originally Posted by Bugsy View Post
These variables are shared between all players on the server.

new stamina
new nbut
new Act

All should be arrays to allow a variable for each individual player:
PHP Code:
#define MAX_PLAYERS 32

new staminaMAX_PLAYERS ]
new 
nbutMAX_PLAYERS ]
new 
ActMAX_PLAYERS ]

//Then use stamina[ id ] 
now stamina is just saying its zero but its still shooting excatly how much i bought
Grovliom is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-10-2020 , 18:40   Re: help!
Reply With Quote #4

Show your new code.
__________________
Bugsy is offline
Grovliom
Member
Join Date: Mar 2020
Location: somewhere in Serbia
Old 06-10-2020 , 18:41   Re: help!
Reply With Quote #5

Quote:
Originally Posted by Bugsy View Post
Show your new code.
Code:
#include <amxmodx> #include <amxmisc> #include <fun> #include <engine> #include <hamsandwich> #include <cstrike> #define MAX_PLAYERS 32 new stamina[ MAX_PLAYERS + 1 ] new nbut[ MAX_PLAYERS + 1 ] new Act[ MAX_PLAYERS + 1 ] new laser new pFrags public plugin_init() {     register_clcmd("say /stamina", "buyStam")     register_clcmd("say_team /stamina", "buyStam") } public buyStam(id) {     new menu = menu_create("Stamina Menu", "menu_handler")     menu_additem(menu, "+10 Stamina - 7000$ -", "", 0)     menu_additem(menu, "+5 Stamina - 4000$ -", "", 0)     menu_additem(menu, "+1 Stamina - 1000$ -", "", 0)     menu_setprop( menu, MPROP_EXIT, MEXIT_ALL );     menu_display(id, menu, 0) } public menu_handler(id, menu, item) {        switch( item )     {         case 0:             {                 if(cs_get_user_money(id) < 7000)                 {                     cs_set_user_money(id, cs_get_user_money(id))                     client_print(id, print_center, "You don't have enough money for that...")                     message_begin(MSG_ONE, get_user_msgid("ScreenFade"), "", id);                     write_short(1024);                     write_short(0);                     write_short(0);                     write_byte(255);                     write_byte(0);                     write_byte(0);                     write_byte(255);                     message_end();                                     }                 else                 {                     if(stamina[id] == 10)                     {                         client_print(id, print_center, "-MAXIMUM STAMINA REACHED-")                         message_begin(MSG_ONE, get_user_msgid("ScreenFade"), "", id);                         write_short(1024);                         write_short(0);                         write_short(0);                         write_byte(255);                         write_byte(0);                         write_byte(0);                         write_byte(255);                         message_end();                     }                     else                     {                         set_task(0.1, "tenst", id)                         menu_destroy( menu );                         return PLUGIN_HANDLED;                     }                 }             }         case 1:             {             if(cs_get_user_money(id) < 4000)                 {                     cs_set_user_money(id, cs_get_user_money(id))                     client_print(id, print_center, "You don't have enough money for that...")                     message_begin(MSG_ONE, get_user_msgid("ScreenFade"), "", id);                     write_short(1024);                     write_short(0);                     write_short(0);                     write_byte(255);                     write_byte(0);                     write_byte(0);                     write_byte(255);                     message_end();                                     }                 else                 {                     if(stamina[id] == 10)                     {                         client_print(id, print_center, "-MAXIMUM STAMINA REACHED-")                         message_begin(MSG_ONE, get_user_msgid("ScreenFade"), "", id);                         write_short(1024);                         write_short(0);                         write_short(0);                         write_byte(255);                         write_byte(0);                         write_byte(0);                         write_byte(255);                         message_end();                     }                     else                     {                         set_task(0.1, "fivest", id)                         menu_destroy( menu );                         return PLUGIN_HANDLED;                     }                 }             }         case 2:             {                 if(cs_get_user_money(id) < 1000)                 {                     cs_set_user_money(id, cs_get_user_money(id))                     client_print(id, print_center, "You don't have enough money for that...")                     message_begin(MSG_ONE, get_user_msgid("ScreenFade"), "", id);                     write_short(1024);                     write_short(0);                     write_short(0);                     write_byte(255);                     write_byte(0);                     write_byte(0);                     write_byte(255);                     message_end();                                     }                 else                 {                     if(stamina[id] == 10)                     {                         client_print(id, print_center, "-MAXIMUM STAMINA REACHED-")                         message_begin(MSG_ONE, get_user_msgid("ScreenFade"), "", id);                         write_short(1024);                         write_short(0);                         write_short(0);                         write_byte(255);                         write_byte(0);                         write_byte(0);                         write_byte(255);                         message_end();                     }                     else                     {                         set_task(0.1, "onest", id)                         menu_destroy( menu );                         return PLUGIN_HANDLED;                     }                 }             }     }     menu_destroy( menu );     return PLUGIN_HANDLED; } public tenst(id) {     stamina[id] = stamina[id] + 10     client_print(id, print_center, "+10 Stamina")     cs_set_user_money(id, cs_get_user_money(id) - 7000) } public fivest(id) {     stamina[id] = stamina[id] + 5     client_print(id, print_center, "+5 Stamina")     cs_set_user_money(id, cs_get_user_money(id) - 4000) } public onest(id) {     stamina[id] = stamina[id] + 1     client_print(id, print_center, "+1 Stamina")     cs_set_user_money(id, cs_get_user_money(id) - 1000) } public plugin_precache() {     laser = precache_model("sprites/laserbeam.spr")     precache_sound("ultramod/zap1.wav") } public client_putinserver(id) {     stamina[id] = 0 } public client_PreThink(id) {        if(is_user_alive(id))     {         pFrags = get_user_frags(id)         set_hudmessage(random(255), random(255), random(255), 0.29, 0.88, 0, 6.0, 0.1)     show_hudmessage(id, "Stamina:%d", stamina)         nbut[id] = get_user_oldbutton(id)         new hit     new body     get_user_aiming(id, hit, body, 9999)         new origin[3], aimorigin[3]     get_user_origin(id,origin)     get_user_origin(id,aimorigin,3)         if(stamina[id] < 0)         {             Act[id] = 1         }     if(stamina[id] > 10)         {             stamina[id] = 10         }     if(Act[id] == 1)         {             Act[id] = 0             stamina[id] = stamina[id] + 1         }     if (nbut[id] == IN_USE)     {         if(stamina[id] == 0)         {                     }         if(stamina[id] > 0)             {                 set_user_health(hit, -1)                 remove_task(id)                 stamina[id] = stamina[id] - 1                 message_begin(MSG_ALL,SVC_TEMPENTITY)                 write_byte(0)         // TE_BEAMPOINTS                 write_coord(origin[0])    // start point                 write_coord(origin[1])                 write_coord(origin[2])                 write_coord(aimorigin[0])   // end point                 write_coord(aimorigin[1])                 write_coord(aimorigin[2])                 write_short(laser)    // sprite to draw (below)                 write_byte(0)         // starting frame                 write_byte(0)         // frame rate                 write_byte(1)         // life in 0.1s                 write_byte(3)         // line width in 0.1                 write_byte(0)         // noise in 0.1                 write_byte(random(255))  // R                 write_byte(random(255))  // G                 write_byte(random(255))  // B                 write_byte(200)   // brightness                 write_byte(2)         // scroll speed                 message_end()             }         }     } }

Last edited by Grovliom; 06-10-2020 at 18:45. Reason: sorry for not putting in pawn
Grovliom is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-10-2020 , 18:44   Re: help!
Reply With Quote #6

Come on man, use php tags like you did originally.
__________________
Bugsy is offline
Grovliom
Member
Join Date: Mar 2020
Location: somewhere in Serbia
Old 06-10-2020 , 18:45   Re: help!
Reply With Quote #7

Quote:
Originally Posted by Bugsy View Post
Come on man, use php tags like you did originally.
there!
Grovliom is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-10-2020 , 18:48   Re: help!
Reply With Quote #8

Do you realize how often client_prethink is called?

You will burn through stamina nearly instantly.
PHP Code:
    if (nbut[id] == IN_USE)
    {
        if(
stamina[id] == 0)
        {
            
        }
        if(
stamina[id] > 0)
            {
                
set_user_health(hit, -1)
                
remove_task(id)
                
stamina[id] = stamina[id] - 
__________________
Bugsy is offline
Grovliom
Member
Join Date: Mar 2020
Location: somewhere in Serbia
Old 06-10-2020 , 18:49   Re: help!
Reply With Quote #9

Quote:
Originally Posted by Bugsy View Post
Do you realize how often client_prethink is called?

You will burn through stamina nearly instantly.
PHP Code:
    if (nbut[id] == IN_USE)
    {
        if(
stamina[id] == 0)
        {
            
        }
        if(
stamina[id] > 0)
            {
                
set_user_health(hit, -1)
                
remove_task(id)
                
stamina[id] = stamina[id] - 
it just kills a player and then it just goes down 1 stamina, worked before with my friend and i!

Last edited by Grovliom; 06-10-2020 at 18:56.
Grovliom is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-10-2020 , 18:58   Re: help!
Reply With Quote #10

What do you expect it to do? Speak in words not code.
__________________
Bugsy is offline
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 06:44.


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