Raised This Month: $ Target: $400
 0% 

box not spawn


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Snitch
Veteran Member
Join Date: Sep 2013
Location: Kazakhstan
Old 08-29-2014 , 18:41   box not spawn
Reply With Quote #1

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();
        }
    }
}
Snitch is offline
Send a message via Skype™ to Snitch
Snitch
Veteran Member
Join Date: Sep 2013
Location: Kazakhstan
Old 09-21-2014 , 10:54   Re: box not spawn
Reply With Quote #2

bump
Snitch is offline
Send a message via Skype™ to Snitch
Snitch
Veteran Member
Join Date: Sep 2013
Location: Kazakhstan
Old 11-23-2014 , 16:44   Re: box not spawn
Reply With Quote #3

bump
Snitch is offline
Send a message via Skype™ to Snitch
Snitch
Veteran Member
Join Date: Sep 2013
Location: Kazakhstan
Old 01-28-2015 , 10:16   Re: box not spawn
Reply With Quote #4

bump
Snitch is offline
Send a message via Skype™ to Snitch
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 01-28-2015 , 17:09   Re: box not spawn
Reply With Quote #5

Try this and post console output

PHP Code:
public logevent_round_start() {

    
client_print(idprint_console"DEBUG*************ROUND STARTED")
    new 
pnum[2], origin[3], minor[2][3], maxor[2][3], bool:compare[2]
    for (new 
1<= MAX_PLAYERS; ++i) {
        if (!
is_user_alive(i))
            continue

        new 
team get_user_team(i) - 1
        
if (team != && team != 1)
            continue

        
pnum[team]++
        
get_user_origin(iorigin)
        if (
compare[team]) {
            for (new 
03; ++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 
01; ++i) {
        
client_print(idprint_console"DEBUG*************SPAWN BOX No %i"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(giftEV_SZ_classnameNAME)
        
entity_set_int(giftEV_INT_solidSOLID_TRIGGER)

        new 
Float:gift_origin[3]
        for (new 
03; ++j)
            
gift_origin[j] = float(random_num(minor[i][j], maxor[i][j]))
        
gift_origin[2] += 30
        entity_set_vector
(giftEV_VEC_origingift_origin)

        
entity_set_model(giftBOX)
        
client_print(idprint_console"DEBUG*************BOX @ %.1f %.1f %.1f"gift_origin[0], gift_origin[1], gift_origin[2])
    }
    
client_print(idprint_console"DEBUG*************END OF ROUND START")

Also, you're not setting size to the entity
__________________
Hey ^_^
NikKOo31 is offline
ironskillz1
AlliedModders Donor
Join Date: Jul 2012
Location: Sweden
Old 01-29-2015 , 02:46   Re: box not spawn
Reply With Quote #6

I made this plugins a long time ago but i guess it still works.
And its simular like you want it.

https://forums.alliedmods.net/showthread.php?t=226414
__________________
I have many private and unique plugins for Jailbreak and Hide'N'Seek. PM me for more info.

Pm me.

Check out my roulette site.
ironskillz1 is offline
Send a message via Skype™ to ironskillz1
Snitch
Veteran Member
Join Date: Sep 2013
Location: Kazakhstan
Old 02-03-2015 , 09:35   Re: box not spawn
Reply With Quote #7

Quote:
Originally Posted by NikKOo31 View Post
Try this and post console output

PHP Code:
public logevent_round_start() {

    
client_print(idprint_console"DEBUG*************ROUND STARTED")
    new 
pnum[2], origin[3], minor[2][3], maxor[2][3], bool:compare[2]
    for (new 
1<= MAX_PLAYERS; ++i) {
        if (!
is_user_alive(i))
            continue

        new 
team get_user_team(i) - 1
        
if (team != && team != 1)
            continue

        
pnum[team]++
        
get_user_origin(iorigin)
        if (
compare[team]) {
            for (new 
03; ++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 
01; ++i) {
        
client_print(idprint_console"DEBUG*************SPAWN BOX No %i"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(giftEV_SZ_classnameNAME)
        
entity_set_int(giftEV_INT_solidSOLID_TRIGGER)

        new 
Float:gift_origin[3]
        for (new 
03; ++j)
            
gift_origin[j] = float(random_num(minor[i][j], maxor[i][j]))
        
gift_origin[2] += 30
        entity_set_vector
(giftEV_VEC_origingift_origin)

        
entity_set_model(giftBOX)
        
client_print(idprint_console"DEBUG*************BOX @ %.1f %.1f %.1f"gift_origin[0], gift_origin[1], gift_origin[2])
    }
    
client_print(idprint_console"DEBUG*************END OF ROUND START")

Also, you're not setting size to the entity
I do not beat compile if I do not define id Public.
This line:
Code:
client_print (id, print_console, "DEBUG ************* ROUND STARTED")
id = undefined
Quote:
Originally Posted by ironskillz1 View Post
I made this plugins a long time ago but i guess it still works.
And its simular like you want it.


https://forums.alliedmods.net/showthread.php?t=226414
do not know how to define what I wanted ..
Snitch is offline
Send a message via Skype™ to Snitch
Snitch
Veteran Member
Join Date: Sep 2013
Location: Kazakhstan
Old 02-20-2015 , 15:32   Re: box not spawn
Reply With Quote #8

bump !
Snitch is offline
Send a message via Skype™ to Snitch
Snitch
Veteran Member
Join Date: Sep 2013
Location: Kazakhstan
Old 03-21-2015 , 14:45   Re: box not spawn
Reply With Quote #9

Quote:
Originally Posted by NikKOo31 View Post
Try this and post console output

PHP Code:
public logevent_round_start() {

    
client_print(idprint_console"DEBUG*************ROUND STARTED")
    new 
pnum[2], origin[3], minor[2][3], maxor[2][3], bool:compare[2]
    for (new 
1<= MAX_PLAYERS; ++i) {
        if (!
is_user_alive(i))
            continue

        new 
team get_user_team(i) - 1
        
if (team != && team != 1)
            continue

        
pnum[team]++
        
get_user_origin(iorigin)
        if (
compare[team]) {
            for (new 
03; ++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 
01; ++i) {
        
client_print(idprint_console"DEBUG*************SPAWN BOX No %i"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(giftEV_SZ_classnameNAME)
        
entity_set_int(giftEV_INT_solidSOLID_TRIGGER)

        new 
Float:gift_origin[3]
        for (new 
03; ++j)
            
gift_origin[j] = float(random_num(minor[i][j], maxor[i][j]))
        
gift_origin[2] += 30
        entity_set_vector
(giftEV_VEC_origingift_origin)

        
entity_set_model(giftBOX)
        
client_print(idprint_console"DEBUG*************BOX @ %.1f %.1f %.1f"gift_origin[0], gift_origin[1], gift_origin[2])
    }
    
client_print(idprint_console"DEBUG*************END OF ROUND START")

Also, you're not setting size to the entity
Code:
DEBUG*************ROUND STARTED
DEBUG*************SPAWN BOX No 0
DEBUG*************BOX @ -831.9 -800.0 193.9
DEBUG*************END OF ROUND START
it spawn on me, i want random in map (30mins)

Last edited by Snitch; 03-27-2015 at 17:03.
Snitch is offline
Send a message via Skype™ to Snitch
Snitch
Veteran Member
Join Date: Sep 2013
Location: Kazakhstan
Old 05-05-2015 , 18:14   Re: box not spawn
Reply With Quote #10

bump
__________________
Қазақстан Республикасы
Snitch is offline
Send a message via Skype™ to Snitch
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 17:56.


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