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

Giving a gift after a bomb explosion


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pokep4
New Member
Join Date: Jan 2024
Old 01-31-2024 , 08:26   Giving a gift after a bomb explosion
Reply With Quote #1

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?

Last edited by pokep4; 01-31-2024 at 08:27.
pokep4 is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 01-31-2024 , 17:42   Re: Giving a gift after a bomb explosion
Reply With Quote #2

Quote:
Originally Posted by pokep4 View Post
..Is it possible...
clear
__________________
mlibre is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-02-2024 , 05:12   Re: Giving a gift after a bomb explosion
Reply With Quote #3

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
__________________
HamletEagle is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 02-09-2024 , 11:26   Re: Giving a gift after a bomb explosion
Reply With Quote #4

could also be used

PHP Code:
public bomb_explode(planterdefuser)
{
    
//c4 exploded

__________________
mlibre is offline
CAN2323
Junior Member
Join Date: Oct 2022
Old 03-08-2024 , 02:50   Re: Giving a gift after a bomb explosion
Reply With Quote #5

Quote:
Originally Posted by pokep4 View Post
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.

Last edited by CAN2323; 03-08-2024 at 02:51.
CAN2323 is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 03-10-2024 , 09:01   Re: Giving a gift after a bomb explosion
Reply With Quote #6

@CAN where did those natives come from?

fact
__________________
mlibre is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 03-10-2024 , 17:24   Re: Giving a gift after a bomb explosion
Reply With Quote #7

Quote:
Originally Posted by mlibre View Post
@CAN where did those natives come from?

fact
from chatgpt
lexzor is offline
Tote
Senior Member
Join Date: Jul 2023
Old 03-14-2024 , 10:28   Re: Giving a gift after a bomb explosion
Reply With Quote #8

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;
}

Last edited by Tote; 03-14-2024 at 10:35.
Tote is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 03-14-2024 , 11:55   Re: Giving a gift after a bomb explosion
Reply With Quote #9

Quote:
Originally Posted by lexzor View Post
from chatgpt
wonderful

@Tote

Quote:
Originally Posted by pokep4 View Post
...randomly select a terrorist...
__________________
mlibre is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 03-14-2024 , 14:00   Re: Giving a gift after a bomb explosion
Reply With Quote #10

Thought AI script writing was unwelcome here and Discord. Script doles CT an AWP half the time. Just like Hitler is black.
__________________
DJEarthQuake 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 11:31.


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