AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need help with a simple plugin (https://forums.alliedmods.net/showthread.php?t=62250)

Claw 10-21-2007 19:10

Need help with a simple plugin
 
Hey, i got this plugin running on my Hide n Seek server.
Its a chance to get items at start of each round plugin ;) I got some extra health, scout, dgl. armor and shield added atm.

Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>

#define Plugin "Weapon Chance"
#define Version "1.0"
#define Author "Doombringer"

#define TIME_TO_WAIT 5.0

public plugin_init()
{
        register_plugin(Plugin, Version, Author)
        register_logevent("round_start", 2, "1=Round_Start")
}

public main_func()
{
        new players[32], num
        get_players(players, num)

        new player
        for(new i = 0; i < num; i++)
        {
                player = players[i]
               
                if(random_num(0, 100) <= 1)
                {                       
                        give_item(player, "weapon_scout")
                       
                        cs_set_user_bpammo(player, CSW_SCOUT, 0)
                        client_print(player, print_chat, "You were lucky, you got a scout with 1 bullet")
                }
               
                if(random_num(0, 100) <= 5)
                {
                        give_item(player, "weapon_deagle")       
                       
                        cs_set_user_bpammo(player, CSW_DEAGLE, 0)
                        client_print(player, print_chat, "You were lucky, you got a deagle with 1 bullet")
                }
               
                if(random_num(0, 100) <= 15)
                {
                        give_item(player, "weapon_hegrenade")
                        client_print(player, print_chat, "You were lucky, you got a HE-grenade")
                }
               
                if(random_num(0, 100) <= 10)
                {
                        give_item(player, "weapon_shield")                       
                        client_print(player, print_chat, "You were lucky, you got a shield")
                }
               
                if(random_num(0, 100) <= 2)
                {
                        set_user_health(player, 200)
                        client_print(player, print_chat, "You were lucky, you got 100 extra health, if you walk on a healer you will loose this extra health")
                }

                if(random_num(0, 100) <= 4)
                {
                        set_user_health(player, 150)
                        client_print(player, print_chat, "You were lucky, you got 50 extra health, if you walk on a healer you will loose this extra health")
                }

                if(random_num(0, 100) <= 8)
                {
                        set_user_health(player, 125)
                        client_print(player, print_chat, "You were lucky, you got 25 extra health, if you walk on a healer you will loose this extra health")
                }

                if(random_num(0, 100) <= 25)
                {
                        cs_set_user_armor(player, 100, CS_ARMOR_VESTHELM)       
                        client_print(player, print_chat, "You were lucky, you got a kevlar and helmet")
                }
}
}

public round_start()
{
        set_task(TIME_TO_WAIT, "main_func")
}

My question is if its possible to make the shield "chance to get" only work for T's?

YamiKaitou 10-21-2007 20:41

Re: Need help with a simple plugin
 
Yes

PHP Code:

if (cs_get_user_team(player) == CS_TEAM_T)
{
    
give_item(player"weapon_shield")
    
client_print(playerprint_chat"You were lucky, you got a shield")
}
else
    
client_print(player,print_chat,"Only Terrorist can get the shield"


Also, I would recommend getting the users health before you give them more health. Because, if they got the 100 extra health, there is a 4% chance to get the 50 extra health, resulting in them losing the 100 they gained already.

Claw 10-22-2007 11:02

Re: Need help with a simple plugin
 
Quote:

Originally Posted by YamiKaitou (Post 544891)
Yes

PHP Code:

if (cs_get_user_team(player) == CS_TEAM_T)
{
    
give_item(player"weapon_shield")
    
client_print(playerprint_chat"You were lucky, you got a shield")
}
else
    
client_print(player,print_chat,"Only Terrorist can get the shield"


Also, I would recommend getting the users health before you give them more health. Because, if they got the 100 extra health, there is a 4% chance to get the 50 extra health, resulting in them losing the 100 they gained already.

Could you maybe show me how to do that, not really the best at scripting ^^

Claw 10-22-2007 12:28

Re: Need help with a simple plugin
 
Code:

               
                if(random_num(0, 100) <= 10)
                if (cs_get_user_team(player) == CS_TEAM_T)
                {
                          give_item(player, "weapon_shield")
                          client_print(player, print_chat, "You were lucky, you got a shield")
                }

and would this work fine?

YamiKaitou 10-22-2007 14:15

Re: Need help with a simple plugin
 
Quote:

Originally Posted by Claw (Post 545067)
Could you maybe show me how to do that, not really the best at scripting ^^

First, we need to define a new variable. So, the line under where you are giving player a value, put this
PHP Code:

new health get_user_health(player); 

Then, in each if block that is setting the health, replace the set_user_health with this
PHP Code:

health += 100;
set_user_health(player,health); 

Then, just change the 100 to how ever much the user is gaining in that block.



Quote:

and would this work fine?
Yeah, that should work fine

Claw 10-22-2007 14:57

Re: Need help with a simple plugin
 
Okey, it seems to be working just great, thanks alot mate ;)

Just one thing, do you think it would be possible to not make players loose their extra health when they go on a block called "Healer" from the Blockmaker 3.51 plugin? If you've ever tested that one.

YamiKaitou 10-22-2007 15:02

Re: Need help with a simple plugin
 
You would have to add a check in the blockmaker code for the healer block taht prevents it from healing if the users health is 100 or larger

Claw 10-22-2007 16:13

Re: Need help with a simple plugin
 
Could you maybe help me with that? :P

Claw 11-16-2007 20:02

Re: Need help with a simple plugin
 
Or maybe someone else would be possible to help me? ^^

dangerix 11-16-2007 22:33

Re: Need help with a simple plugin
 
You are the one who is asking for help.
So, maybe you're the one who is supposed to provide any information / source code / whatever necessary?

Actually, it looks like it is adding 1 line or so.


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

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