I can't understand the reason of your request !
- While you were able to generate random points , So I believe that you can save them in a txt file automatically without the need of hand typing!
- You can either edit the source code of 'CSSDM' by managing the part where the plugin is trying to read that txt file , then replace that function with a direct supply of
your coordinates [those that was generated based on x seconds and y meters].
Anyway , If you want to dive alone and get independent of that sticky 'CSSDM' :
[ANY] Dynamic/Random Spawnpoints
PHP Code:
#include <sdktools>
#define Timer_Interval 5.0
#define POINTS_LIMIT 200
#define Cubit 50.0
Handle hTimer[MAXPLAYERS+1];
float RandomPos[POINTS_LIMIT][3];
int count;
bool safepoint[MAXPLAYERS+1];
public OnPluginStart(){
HookEvent("player_spawn", event_player_spawn , EventHookMode_Post);
}
public event_player_spawn(Handle event, char[] event_name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
if (!IsValidHandle(hTimer[client]))
hTimer[client] = CreateTimer(Timer_Interval ,Timer_Scan ,client, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
if (count){ // your array is carrying some points
safepoint[client] = true;
int rand = GetRandomInt(0,count-1);
TR_EnumerateEntitiesSphere(RandomPos[rand] , Cubit , PARTITION_NON_STATIC_EDICTS, Entities_Nearby_Enumerator, client);
if ( safepoint[client] )
TeleportEntity( client , RandomPos[rand] , NULL_VECTOR , NULL_VECTOR);
else
PrintToChat(client , "failed to teleport");
}
}
public Action Timer_Scan(Handle timer , any client){
if (count < POINTS_LIMIT){
if (IsWalking(client) && !UnderCeil(client) )
GetClientAbsOrigin(client , RandomPos[count++]);
else
PrintToChat(client , "failed to save point");
return Plugin_Continue;
}
return Plugin_Stop;
}
public OnClientDisconnect(int client){
if (IsValidHandle(hTimer[client]))
KillTimer(hTimer[client]);
}
public OnMapEnd(){
char CMap[32];
GetCurrentMap(CMap, 32);
LogMessage("%s Valid Spawn Positions :" , CMap);
for (int i=0 ; i<count ; i++)
LogMessage("[%f , %f , %f]" , RandomPos[i][0] , RandomPos[i][1] , RandomPos[i][2]);
count = 0;
}
bool Entities_Nearby_Enumerator(int entity, int client){
return (safepoint[client] = entity < 1 || entity > MaxClients); // if true , the fucntion will continue enumerating the surrounded entities until it finds a valid player [so false means : stop enumerating]
}
bool UnderCeil(client){
static float pos1[3],pos2[3];
GetClientEyePosition(client , pos1);
pos2[0] = pos1[0];
pos2[1] = pos1[1];
pos2[2] = pos1[2] + Cubit;
TR_TraceRay(pos1, pos2, MASK_SOLID , RayType_EndPoint);
return TR_DidHit();
}
bool IsWalking(int client){
return ( (GetEntityMoveType(client) == MOVETYPE_WALK) && GetVelocity(client) > 0 )
}
stock float GetVelocity(int client){
static float vel[3];
GetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", vel);
return GetVectorLength(vel);
}