Raised This Month: $32 Target: $400
 8% 

Random Respawn Pos


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wlsrhkd41
Member
Join Date: Oct 2015
Old 06-11-2016 , 07:51   Random Respawn Pos
Reply With Quote #1

is there random respawn plugin? like in DM plugin

i searched all of the site, but i cant find this plugin

i am looking for i can set the pos and the pos save in "sourcemod/config/*.txt" like this

and if round start player spawn in .txt pos

some dev users can make this plugin? or have this pluin
wlsrhkd41 is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 06-11-2016 , 08:04   Re: Random Respawn Pos
Reply With Quote #2

So... it's not random but rather pre-configured spawn positions ? I think I have something like this on my PC...
__________________
Want to check my plugins ?

Last edited by Arkarr; 06-11-2016 at 08:04.
Arkarr is offline
wlsrhkd41
Member
Join Date: Oct 2015
Old 06-11-2016 , 08:22   Re: Random Respawn Pos
Reply With Quote #3

Quote:
Originally Posted by Arkarr View Post
So... it's not random but rather pre-configured spawn positions ? I think I have something like this on my PC...
oh really ?

can i get your plugin ??
wlsrhkd41 is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 06-11-2016 , 09:09   Re: Random Respawn Pos
Reply With Quote #4

Well, I didn't found it, so I recreated it, not tested through :
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <colors>

#define PLUGIN_AUTHOR             "Arkarr"
#define PLUGIN_VERSION             "1.00"
#define PLUGIN_TAG                "[Spawn Editor]"
#define PLUGIN_CTAG                "{green}[Spawn Editor]{default}"

#define CUSTOM_SPAWN_ENABLED    "CUSTOM_SPAWN_ENABLED"
#define POSITION_X                "POSITION_X"
#define POSITION_Y                "POSITION_Y"
#define POSITION_Z                "POSITION_Z"

Handle ARRAY_Spawns;

bool PluginEnabled;

int NumberOfSpawns;

public 
Plugin myinfo 
{
    
name "[ANY] Spawn Editor",
    
author PLUGIN_AUTHOR,
    
description "Allow you to edit default spawn location",
    
version PLUGIN_VERSION,
    
url "http://www.sourcemode.net"
};

public 
void OnPluginStart()
{
    
ARRAY_Spawns CreateArray();
    
HookEvent("player_spawn"Event_PlayerSpawn);
    
    
RegAdminCmd("sm_createspawn"CMD_CreateSpawnADMFLAG_CHANGEMAP"Create a new spawn location");
}

public 
void OnMapStart()
{
    
char mapName[45];
    
GetCurrentMap(mapNamesizeof(mapName));
    
PluginEnabled LoadConfiguration(mapName);
    
    if(!
PluginEnabled)
        
PrintToServer("%s Plugin is DISABLED"PLUGIN_TAG);
}

public 
void OnMapEnd()
{
    
SaveConfiguration();    
}

public 
Action CMD_CreateSpawn(clientargs)
{
    if(!
PluginEnabled)
        return 
Plugin_Handled;
        
    if(
client == 0)
    {
        
PrintToServer("%s This command is restricted to in-game."PLUGIN_TAG);
        return 
Plugin_Handled;
    }
    
    
float newSpawn[3];
    
GetEntPropVector(clientProp_Send"m_vecOrigin"newSpawn);
    
    
Handle trie CreateTrie();
    
SetTrieValue(triePOSITION_XnewSpawn[0]);
    
SetTrieValue(triePOSITION_YnewSpawn[1]);
    
SetTrieValue(triePOSITION_ZnewSpawn[2]);
    
PushArrayCell(ARRAY_Spawnstrie);
    
    
CPrintToChat(client"%s New spawn added :D !"PLUGIN_CTAG);
    
    
NumberOfSpawns++;
    
    return 
Plugin_Handled;
}

public 
void Event_PlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    if(!
PluginEnabled)
        return;
    
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    
    if(!
IsValidClient(client))
        return;
    
    
PrintToChatAll("New spawn ID between : 0 - %i", (NumberOfSpawns-1));
    
int spawnID GetRandomInt(0NumberOfSpawns-1);
    
Handle positions GetArrayCell(ARRAY_SpawnsspawnID);
    
    
float newSpawn[3];
    
GetTrieValue(positionsPOSITION_XnewSpawn[0]);
    
GetTrieValue(positionsPOSITION_YnewSpawn[1]);
    
GetTrieValue(positionsPOSITION_ZnewSpawn[2]);
    
    
TeleportEntity(clientnewSpawnNULL_VECTORNULL_VECTOR);
}

stock void SaveConfiguration()
{
    
char path[75], mapName[45];
    
GetCurrentMap(mapNamesizeof(mapName));    
    
    
BuildPath(Path_SMpathsizeof(path), "configs/SpawnEditor/%s.cfg"mapName);
    
    
Handle file OpenFile(path,"w");
    
WriteFileLine(file"%s=%s"CUSTOM_SPAWN_ENABLED, (PluginEnabled "TRUE" "FALSE"));
    for(
int i 0GetArraySize(ARRAY_Spawns); i++)
    {
        
Handle trie GetArrayCell(ARRAY_Spawnsi);
        
float Px 0.0;
        
float Py 0.0;
        
float Pz 0.0;
        
GetTrieValue(triePOSITION_XPx);
        
GetTrieValue(triePOSITION_YPy);
        
GetTrieValue(triePOSITION_ZPz);
        
WriteFileLine(file"%f;%f;%f"PxPyPz);
    }
}

stock bool LoadConfiguration(const char[] mapName)
{
    
char path[75];
    
BuildPath(Path_SMpathsizeof(path), "configs/SpawnEditor/%s.cfg"mapName);
    
    if(!
DirExists("addons/sourcemod/configs/SpawnEditor"))
         
CreateDirectory("/addons/sourcemod/configs/SpawnEditor"777);
    
    
Handle file INVALID_HANDLE;
    if(!
FileExists(path))
        
file OpenFile(path,"w");
    else
        
file OpenFile(path"r");
        
    
char line[200];
    
bool firstLine true;
    
ClearArray(ARRAY_Spawns);
    
    while(!
IsEndOfFile(file) && ReadFileLine(filelinesizeof(line)))
    {
        if(
firstLine)
        {
            if(
StrContains(lineCUSTOM_SPAWN_ENABLED) == 0)
            {
                if(
StrContains(line"FALSE"false) != -1)
                    return 
false;
                
firstLine false;
            }
        }
        else
        {
            
char positions[3][15];
            
ExplodeString(line";"positionssizeof positionssizeof positions[]);
            
            
Handle trie CreateTrie();
            
SetTrieValue(triePOSITION_XStringToFloat(positions[0]));
            
SetTrieValue(triePOSITION_YStringToFloat(positions[1]));
            
SetTrieValue(triePOSITION_ZStringToFloat(positions[2]));
            
            
PushArrayCell(ARRAY_Spawnstrie);
        }
    }
    
CloseHandle(file);
    
    if(
firstLine)
    {
        
PrintToServer("%s NO CONFIGURATION FOUND !"PLUGIN_TAG);
        
PrintToServer("%s Default spawn will be used !"PLUGIN_TAG);
        return 
false;    
    }
    
    
NumberOfSpawns GetArraySize(ARRAY_Spawns)
    
    if(
NumberOfSpawns 1)
        
PrintToServer("%s ZERO SPAWNS FOUND !"PLUGIN_TAG);
    else
        
PrintToServer("%s LOADED %i CUSTOM SPAWNS !"PLUGIN_TAGNumberOfSpawns);
        
    return 
true;
}


stock bool IsValidClient(int client)
{
    if (
client <= 0)return false;
    if (
client MaxClients)return false;
    if (!
IsClientConnected(client))return false;
    return 
IsClientInGame(client);

Any donation thankfully accepted...
__________________
Want to check my plugins ?

Last edited by Arkarr; 06-11-2016 at 10:53.
Arkarr is offline
wlsrhkd41
Member
Join Date: Oct 2015
Old 06-11-2016 , 09:30   Re: Random Respawn Pos
Reply With Quote #5

oh thanks alot ! i will test it later
how to donate to you ?? there is no donate botton

Last edited by wlsrhkd41; 06-11-2016 at 11:54.
wlsrhkd41 is offline
wlsrhkd41
Member
Join Date: Oct 2015
Old 06-11-2016 , 09:46   Re: Random Respawn Pos
Reply With Quote #6

Quote:
Originally Posted by Arkarr View Post
So... it's not random but rather pre-configured spawn positions ? I think I have something like this on my PC...
i tested it but creat SpawnEditor folders fine

but if i say in console sm_createspawn nothing happened, i added me server admin

created *.cfg fine

but it didnt add the pos in cfg

Last edited by wlsrhkd41; 06-11-2016 at 09:48.
wlsrhkd41 is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 06-11-2016 , 10:35   Re: Random Respawn Pos
Reply With Quote #7

Quote:
Originally Posted by wlsrhkd41 View Post
i tested it but creat SpawnEditor folders fine

but if i say in console sm_createspawn nothing happened, i added me server admin

created *.cfg fine

but it didnt add the pos in cfg
It means that the plugin is disabled. To enable it, just change the first line of the config file to 'TRUE' and reload the plugin. Config file is created automatically, you really don't have to edit any files except if you want to disable the plugin on some specific map.
See my exemple below :
PHP Code:
CUSTOM_SPAWN_ENABLED=TRUE
43.4324
;20.434324;52.4142
NOTE:
I update my code above, so please, do it also ;) !

To donate, just click on my image, in my signature.
__________________
Want to check my plugins ?

Last edited by Arkarr; 06-11-2016 at 10:46.
Arkarr is offline
wlsrhkd41
Member
Join Date: Oct 2015
Old 06-11-2016 , 13:29   Re: Random Respawn Pos
Reply With Quote #8

Quote:
Originally Posted by Arkarr View Post
It means that the plugin is disabled. To enable it, just change the first line of the config file to 'TRUE' and reload the plugin. Config file is created automatically, you really don't have to edit any files except if you want to disable the plugin on some specific map.
See my exemple below :
PHP Code:
CUSTOM_SPAWN_ENABLED=TRUE
43.4324
;20.434324;52.4142
NOTE:
I update my code above, so please, do it also ;) !

To donate, just click on my image, in my signature.
it have some problem what, always i have to sm plugins reload randomspawn
because if i open server, the cfg's pos del so if i reload plugin, pos appeal
i saved pos and exit server, in cfg there is pos but server open pos and CUSTOM_BLABLA=TRUE is disappeal
and in server console print "no configuration found, default spawn will be used, plugin is Disabled."

Last edited by wlsrhkd41; 06-11-2016 at 13:34.
wlsrhkd41 is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 06-11-2016 , 14:15   Re: Random Respawn Pos
Reply With Quote #9

Quote:
Originally Posted by wlsrhkd41 View Post
it have some problem what, always i have to sm plugins reload randomspawn
because if i open server, the cfg's pos del so if i reload plugin, pos appeal
i saved pos and exit server, in cfg there is pos but server open pos and CUSTOM_BLABLA=TRUE is disappeal
and in server console print "no configuration found, default spawn will be used, plugin is Disabled."
Position are saved on map change or server shutdown.
__________________
Want to check my plugins ?
Arkarr is offline
Reply


Thread Tools
Display Modes

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 01:45.


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