Raised This Month: $ Target: $400
 0% 

Spawn Generator


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Xalus
Veteran Member
Join Date: Dec 2009
Location: Belgium
Old 12-22-2011 , 19:29   Spawn Generator
Reply With Quote #1

I made this version for my Call Of Duty mw2 Mod,

I don't know if its a good way,
but if U think its usefull,
Have fun with it.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN "Spawn generator"
#define VERSION "1.0"
#define AUTHOR "Xalus"

#define MAX_SPAWNS 100

new SpawnscSpawns
new Float:originSpawn[MAX_SPAWNS][3]
new 
iMaxPlayers

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Cvar's
    
cSpawns    register_cvar("spawngenerator_spawns""2");
    
    
// Player Killed
    
RegisterHam(Ham_Spawn"player""Ham_PlayerSpawn"1);
    
RegisterHam(Ham_Killed"player""Ham_PlayerKilled");
    
    
// Others
    
iMaxPlayers get_maxplayers()
}
public 
Ham_PlayerSpawn(id) {
    if(
is_user_alive(id) && Spawns >= get_pcvar_num(cSpawns)) {
        
client_print(0print_chat"Finding a nice spot for you")
        
        new 
randomSpawn 
        
        GetNewRandomSpawn
:
        
        
randomSpawn random(Spawns)
        if(!
is_player_close(randomSpawn))
            
engfunc(EngFunc_SetOriginidoriginSpawn[randomSpawn])
        else 
            goto 
GetNewRandomSpawn
    
}
}
public 
Ham_PlayerKilled(idiAttacker) {
    if(
id != iAttacker
    
&& Spawns MAX_SPAWNS) {
        
pev(idpev_originoriginSpawn[Spawns])

        if( !
is_user_stuck(idoriginSpawn[Spawns])
        && 
engfunc(EngFunc_PointContentsoriginSpawn[Spawns]) == CONTENTS_EMPTY
        
&& !is_spawn_close(Spawns) ) {
            
Spawns++
                
            if(
Spawns == get_pcvar_num(cSpawns))
                
client_print(0print_center"Random spawns activated!")
        }
    }
}
stock is_user_stuck(const idFloat:Origin[3]) {
    static 
tr
    engfunc
(EngFunc_TraceHullOriginOriginIGNORE_MONSTERSpev(idpev_flags) & FL_DUCKING HULL_HEAD HULL_HUMANidtr)
    
    if( (!
get_tr2(trTR_StartSolid) && !get_tr2(trTR_AllSolid) && get_tr2(trTR_InOpen)) || (pev(id,pev_solid) & SOLID_NOT))
        return 
0

    
return 1
}
stock is_spawn_close(const spawnID) {
    for(new 
0Spawnsi++) 
        if(
get_distance_f(originSpawn[spawnID], originSpawn[i]) < 350.0)
            return 
1
    
return 0
}
stock is_player_close(const spawnID) {
    new 
Float:playerOrigin[3]
    for(new 
1<= iMaxPlayersi++) {
        if(!
is_user_alive(i))
            continue
        
        
pev(ipev_originplayerOrigin)
        
        if(
get_distance_f(originSpawn[spawnID], playerOrigin) < 10.0)
            return 
1
    
}
    return 
0
}


The system:

- When a player die, it will save his origins (If hes not stuck), and when the cvar (spawngenerator_spawns) is reached, it will spawn players on those origins.
- It will get enabled when the cvar is reached. Else its just to the spawn.

If U got some improvements, post them!

Btw this is made for Deathmatch mode, so everyone won't spawn at once.
__________________
Retired.

Last edited by Xalus; 12-23-2011 at 13:18.
Xalus is offline
 



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 20:50.


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