what the problem on this code?
This is the RoundTime or amount Rounds?
the supplybox not spawn at map - xmf.
I want to have a message when it spawn
Code:
#include < amxmodx >
#include < engine >
native get_user_cash(index);
native set_user_cash(index, amount);
#define MAX_PLAYERS 32
#define BOX "models/SupplyBox.mdl"
#define NAME "gift"
public plugin_init() {
register_plugin("Spawn Box", "1.3", "unnamed")
register_touch(NAME, "player", "touch_gift")
register_logevent("logevent_round_start", 2, "0=World triggered", "1=Round_Start")
register_event("RoundTime", "event_round_time", "bc")
}
public plugin_modules() {
require_module("engine")
require_module("fun")
}
public plugin_precache() {
precache_model(BOX)
}
public logevent_round_start() {
new pnum[2], origin[3], minor[2][3], maxor[2][3], bool:compare[2]
for (new i = 1; i <= MAX_PLAYERS; ++i) {
if (!is_user_alive(i))
continue
new team = get_user_team(i) - 1
if (team != 0 && team != 1)
continue
pnum[team]++
get_user_origin(i, origin)
if (compare[team]) {
for (new j = 0; j < 3; ++j) {
if (origin[j] < minor[team][j])
minor[team][j] = origin[j]
if (origin[j] > maxor[team][j])
maxor[team][j] = origin[j]
}
}
else {
minor[team] = origin
maxor[team] = origin
compare[team] = true
}
}
for (new i = 0; i < 1; ++i) {
if (pnum[i] < 1)
continue
new gift = create_entity("info_target")
if (!gift) {
log_amx("ERROR: Couldn't create Spawn Box.")
continue
}
entity_set_string(gift, EV_SZ_classname, NAME)
entity_set_int(gift, EV_INT_solid, SOLID_TRIGGER)
new Float:gift_origin[3]
for (new j = 0; j < 3; ++j)
gift_origin[j] = float(random_num(minor[i][j], maxor[i][j]))
gift_origin[2] += 30
entity_set_vector(gift, EV_VEC_origin, gift_origin)
entity_set_model(gift, BOX)
}
}
public touch_gift(gift, id) {
new RandomAmount = random_num(3000, 9000);
set_user_cash(id, get_user_cash(id) + RandomAmount);
ColorChat(0, "%s Take SupplyBox Event and Gain^4 %i Cash^1.", GetUserName(id), RandomAmount);
remove_entity(gift)
}
public event_round_time() {
if (read_data(1) == get_cvar_num("mp_freezetime")) {
new gift = 0
while ((gift = find_ent_by_class(gift, NAME)))
remove_entity(gift)
}
}
stock GetUserName( client )
{
static szName[ 32 ];
get_user_name( client, szName, charsmax( szName ) );
return szName;
}
stock ColorChat(const id,const string[],any:...){
new msg[191], players[32], count = 1;
static len; len = formatex(msg,charsmax(msg),"^4[K.o.D]^1 ");
vformat(msg[len],charsmax(msg) - len,string,3);
static msgSayText;
if (!msgSayText)
msgSayText = get_user_msgid("SayText");
if(id) players[0] = id;
else get_players(players,count,"ch");
for (new i = 0; i < count; i++)
{
if(is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE,msgSayText,.player = players[i]);
write_byte(players[i]); // Sender ID
write_string(msg); // String 1
message_end();
}
}
}