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

Random spawn location


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 03-25-2017 , 19:21   Random spawn location
Reply With Quote #1

I have gift plugin which spawns gift on round start at each team's spawn.

I want it to spawn anywhere on map instead of CT/T base.

Spawn code:

PHP Code:
public logevent_round_start() 
{
    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 
02; ++i) {
        if (
pnum[i] < 2)
            continue;

        new 
gift create_entity("info_target");
        if (!
gift) {
            
log_amx("ERROR: Couldn't create gift entity!");
            continue;
        }

        
entity_set_string(giftEV_SZ_classnameGIFT_NAME);
        
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(giftGIFT_MODEL);
        
set_pev(giftpev_framerate1.0);
    
        
set_pev(giftpev_renderfxkRenderFxGlowShell);
        
set_pev(giftpev_renderamt1.0);
        
set_pev(giftpev_rendercolor, {32.032.032.0});
    }

__________________
Airkish is offline
D3XT3R
AlliedModders Donor
Join Date: Nov 2016
Location: Lithuania, Bomb A (Kauna
Old 03-26-2017 , 04:49   Re: Random spawn location
Reply With Quote #2

Quote:
Originally Posted by Airkish View Post
I have gift plugin which spawns gift on round start at each team's spawn.

I want it to spawn anywhere on map instead of CT/T base.

Spawn code:

PHP Code:
public logevent_round_start() 
{
    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 
02; ++i) {
        if (
pnum[i] < 2)
            continue;

        new 
gift create_entity("info_target");
        if (!
gift) {
            
log_amx("ERROR: Couldn't create gift entity!");
            continue;
        }

        
entity_set_string(giftEV_SZ_classnameGIFT_NAME);
        
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(giftGIFT_MODEL);
        
set_pev(giftpev_framerate1.0);
    
        
set_pev(giftpev_renderfxkRenderFxGlowShell);
        
set_pev(giftpev_renderamt1.0);
        
set_pev(giftpev_rendercolor, {32.032.032.0});
    }

give us full code.
and if you want it spawn every were in map you should use ini fille and then get loaded every map change and use command to creat spawn points this can helpfull to u.
__________________
D3XT3R is offline
Send a message via Skype™ to D3XT3R
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 03-27-2017 , 13:33   Re: Random spawn location
Reply With Quote #3

Quote:
Originally Posted by D3XT3R View Post
give us full code.
and if you want it spawn every were in map you should use ini fille and then get loaded every map change and use command to creat spawn points this can helpfull to u.
1. Why would u need full code if coordinates are written in the code I gave?
2. And no I dont want to create coords by myself, I just want it to spawn anywhere on map's ground
__________________
Airkish is offline
D3XT3R
AlliedModders Donor
Join Date: Nov 2016
Location: Lithuania, Bomb A (Kauna
Old 03-27-2017 , 14:12   Re: Random spawn location
Reply With Quote #4

try add this to ur plugin:
PS: if u was post full code was easy to help u to add it but try with ur self
PHP Code:
public plugin_init()
{
    
register_clcmd("GiftSpawn""CmdGift");
// ur code
}

public 
plugin_cfg()
{
    new 
g_map[32]
    
get_mapname(g_mapcharsmax(g_map))
    
formatex(g_mapfilecharsmax(g_mapfile), "addons/amxmodx/configs/gift/%s.cfg"g_map//hier ur spawn points save.
    
load_spawns()
}

public 
CmdGift(id)
{
    if(!(
get_user_flags(id) & ADMIN_RCON)) { return PLUGIN_CONTINUE; }
    
    new 
float:origin[3], string[200];
    
get_user_origin(idorigin0);
    
format(string199"%d.0 %d.0 %d.0"origin[0], origin[1], origin[2]);
    
write_file(g_mapfilestring);
    
    
client_print(idprint_chat"Vieta isaugota - %d %d %d"origin[0], origin[1], origin[2]);
    
    return 
PLUGIN_HANDLED;
}

stock load_spawns()
{
    
g_total_gifts 0
    
if (file_exists(g_mapfile))
    {
        static 
supdata[3][6], filelinedata[128];file fopen(g_mapfile,"rt")
        
        while (
file && !feof(file))
        {
            
fgets(filelinedatacharsmax(linedata))
            
            if(!
linedata[0] || str_count(linedata,' ') < 2) continue
            
            
parse(linedata,supdata[0],5,supdata[1],5,supdata[2],5)

            
g_spawns[g_total_gifts][0] = floatstr(supdata[0])
            
g_spawns[g_total_gifts][1] = floatstr(supdata[1])
            
g_spawns[g_total_gifts][2] = floatstr(supdata[2])
            
            
place_box(g_total_gifts)
            
            
g_total_gifts++
        }
        if (
filefclose(file)
    }

__________________
D3XT3R is offline
Send a message via Skype™ to D3XT3R
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 03-27-2017 , 15:46   Re: Random spawn location
Reply With Quote #5

This is not what I asked for.
__________________
Airkish is offline
D3XT3R
AlliedModders Donor
Join Date: Nov 2016
Location: Lithuania, Bomb A (Kauna
Old 03-28-2017 , 04:32   Re: Random spawn location
Reply With Quote #6

Quote:
Originally Posted by Airkish View Post
This is not what I asked for.
i didnt understand realy what you mean....
__________________
D3XT3R is offline
Send a message via Skype™ to D3XT3R
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-28-2017 , 13:18   Re: Random spawn location
Reply With Quote #7

You can't understand what he means unless you learn English properly.

@Airkish - I really don't see how a plugin would automatically know what spawn point is appropriate. If it spawns them everywhere, it's basically EVERYWHERE. So, everywhere would include places unavailable for players. It will be most reliable to set the coordinates manually.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 03-28-2017 , 13:26   Re: Random spawn location
Reply With Quote #8

Quote:
Originally Posted by OciXCrom View Post
You can't understand what he means unless you learn English properly.

@Airkish - I really don't see how a plugin would automatically know what spawn point is appropriate. If it spawns them everywhere, it's basically EVERYWHERE. So, everywhere would include places unavailable for players. It will be most reliable to set the coordinates manually.
I was expecting this answer, well then I will set them manually.
__________________
Airkish is offline
sb123
Senior Member
Join Date: Jan 2007
Old 04-02-2017 , 12:10   Re: Random spawn location
Reply With Quote #9

Try this plugin
Attached Files
File Type: sma Get Plugin or Get Source (VIP_Box.sma - 1388 views - 3.6 KB)
__________________
sb123 is offline
Send a message via ICQ to sb123 Send a message via MSN to sb123 Send a message via Yahoo to sb123
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 23:46.


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