AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Giving a gift after a bomb explosion (https://forums.alliedmods.net/showthread.php?t=345810)

pokep4 01-31-2024 08:26

Giving a gift after a bomb explosion
 
Hello. It is not possible to implement the issuance of awp after the explosion/clearance of a bomb?
And how to random
If possible -
Is it possible to randomly select a terrorist who will receive a bonus?

mlibre 01-31-2024 17:42

Re: Giving a gift after a bomb explosion
 
Quote:

Originally Posted by pokep4 (Post 2817053)
..Is it possible...

clear

HamletEagle 02-02-2024 05:12

Re: Giving a gift after a bomb explosion
 
Absolutely. The below resources may be helpful:
1. How to detect bomb explosion, defusion, and other events? https://forums.alliedmods.net/showthread.php?t=40164
2. How to pick a random terrorist? https://forums.alliedmods.net/showthread.php?t=301304
3. To give a weapon to the identified player: https://amxmodx.org/api/fun/give_item

mlibre 02-09-2024 11:26

Re: Giving a gift after a bomb explosion
 
could also be used

PHP Code:

public bomb_explode(planterdefuser)
{
    
//c4 exploded



CAN2323 03-08-2024 02:50

Re: Giving a gift after a bomb explosion
 
Quote:

Originally Posted by pokep4 (Post 2817053)
Hello. It is not possible to implement the issuance of awp after the explosion/clearance of a bomb?
And how to random
If possible -
Is it possible to randomly select a terrorist who will receive a bonus?

#include <amxmodx>
#include <fun>

new bool:bonused

public plugin_init() {
register_plugin("BombBonus", "1.0", "CAN")
register_clcmd("bonus", "cmd_bonus")
return PLUGIN_CONTINUE
}

public client_putinserver(id) {
if (bonused[id]) {
bonused[id] = false
client_remove_max_money(id, 3300)
client_give_max_money(id)
}
return PLUGIN_CONTINUE
}

public client_disconnect(id) {
bonused[id] = false
return PLUGIN_CONTINUE
}

public cmd_bonus(id) {
if (!is_user_alive(id)) {
client_print(id, print_center, "You must be alive to receive the bonus!")
return PLUGIN_HANDLED
}

if (get_team(id) != TEAM_TERRORIST) {
client_print(id, print_center, "You must be a terrorist to receive the bonus!")
return PLUGIN_HANDLED
}

if (bonused[id]) {
client_print(id, print_center, "You have already received the bonus!")
return PLUGIN_HANDLED
}

for (int i = 1; i <= maxclients(); i++) {
if (get_team(i) == TEAM_TERRORIST && !bonused[i]) {
bonused[i] = true
client_print(i, print_center, "You have received an AWP!")
client_remove_max_money(i, 3300)
client_give_named_item(i, "weapon_awp")
break
}
}

return PLUGIN_HANDLED
}
In this example, the bonused array keeps track of which players have already received the bonus. The cmd_bonus function is called when a player types the !bonus command. It checks if the player is alive and a terrorist, and if they haven't already received the bonus. Then, it iterates through all the terrorist players and randomly selects one to receive the AWP.

mlibre 03-10-2024 09:01

Re: Giving a gift after a bomb explosion
 
@CAN where did those natives come from?

fact

lexzor 03-10-2024 17:24

Re: Giving a gift after a bomb explosion
 
Quote:

Originally Posted by mlibre (Post 2819268)
@CAN where did those natives come from?

fact

from chatgpt

Tote 03-14-2024 10:28

Re: Giving a gift after a bomb explosion
 
Code:

#include <amxmodx>
#include <fun>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Author"


public plugin_init() {
        register_plugin(PLUGIN, VERSION, AUTHOR)
       
        // Add your code here...
}

public bomb_explode()
{
        static player, iPnum, players[32]
        get_players(players, iPnum)
       
        player = players[random(iPnum)];
       
        if(!player) return PLUGIN_CONTINUE;
       
        give_item(player, "weapon_awp")
}

little bit advanced version

Code:

#include <amxmodx>
#include <fun>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Author"

new iType;

public plugin_init() {
        register_plugin(PLUGIN, VERSION, AUTHOR)
       
        // Add your code here...
       
        iType = register_cvar("choose_method", "1") // 1 = Choose random player after Explosion, 2 = Choose defuser after Explosion & 3 = Choose planter after Explosion
}

public bomb_explode(planter, defuser)
{
        if(get_pcvar_num(iType) == 1)
        {
                static player, iPnum, players[32]
                get_players(players, iPnum)
       
                player = players[random(iPnum)];
       
                if(!player) return PLUGIN_CONTINUE;
       
                give_item(player, "weapon_awp")
        }
        else if(get_pcvar_num(iType) == 2)
        {
                give_item(defuser, "weapon_awp")
        }
        else if(get_pcvar_num(iType) == 3)
        {
                give_item(planter, "weapon_awp")
        }
        return PLUGIN_HANDLED;
}


mlibre 03-14-2024 11:55

Re: Giving a gift after a bomb explosion
 
Quote:

Originally Posted by lexzor (Post 2819295)
from chatgpt

wonderful

@Tote

Quote:

Originally Posted by pokep4 (Post 2817053)
...randomly select a terrorist...


DJEarthQuake 03-14-2024 14:00

Re: Giving a gift after a bomb explosion
 
Thought AI script writing was unwelcome here and Discord. Script doles CT an AWP half the time. Just like Hitler is black.

mlibre 03-14-2024 20:58

Re: Giving a gift after a bomb explosion
 
Quote:

Originally Posted by Jhob94 (Post 2809771)
AI can NOT program pawn right now. Pretty much everything it will tell you is wrong.

Quote:

Originally Posted by meTaLiCroSS (Post 2810571)
Just proven this by teaching ChatGPT how SQLx works in AMXX plugins; just a leisure moment, but the AI didn't understand either

it can give us ideas but it is not a complete complement as such, always open to making corrections "optimizations" for its purpose.

Tote 03-15-2024 08:06

Re: Giving a gift after a bomb explosion
 
Quote:

Originally Posted by mlibre (Post 2819476)
wonderful

@Tote

My bad, didn't see. here you go hm

Code:

#include <amxmodx>
#include <fun>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Author"


public plugin_init() {
        register_plugin(PLUGIN, VERSION, AUTHOR)
       
        // Add your code here...
}

public bomb_explode()
{
        static player, iPnum, players[32]
        get_players(players, iPnum, "e", "TERRORIST");
       
        player = players[random(iPnum)];
       
        if(!player) return PLUGIN_CONTINUE;
       
        give_item(player, "weapon_awp")
       
        return PLUGIN_HANDLED;
}


mlibre 03-15-2024 10:37

Re: Giving a gift after a bomb explosion
 
additionally, I would check if the chosen one has the AWP or not, if not, I would choose another, as well as ensuring that the same player is not repeated in consecutive rounds.

DJEarthQuake 03-16-2024 08:51

Re: Giving a gift after a bomb explosion
 
Comments after testing this idea. I made a similar script from the spirit of this thread the day of. When testing after seeing if they already have an AWP it is pointless and decided after checking to just to give them money. If they already have 16k and an AWP well this petered out fast. So I wound up making it 'Kevlar Tape' for a bonus. Everybody could always use some extra padding. Armor seemed to be the most useful.


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

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