public OnPlayerSpawn(playerid)
{
LoadSpawnPosition("EQRP/Server/Spawnpos.ini");
return 1;
}
if(strcmp(cmd, "/setspawn", true) == 0)
{
if(PlayerInfo[playerid][pLogged] == 1)
{
if(PlayerInfo[playerid][pAdmin] >= 1337)
{
new File:SpawnPos = fopen("EQRP/Server/Spawnpos.ini", io_append);
if(SpawnPos)
{
new Float: X, Float: Y, Float: Z, Float: A;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, A);
format(string, sizeof(string), "Player Spawn has been changed to: [%f], [%f], [%f], [%f]", X, Y, Z, A);
SendClientMessage(playerid, COLOR_ADMIN, string);
format(string, sizeof(string), "%f, %f, %f, %f", X, Y, Z, A);
fwrite(SpawnPos, string);
}
fclose(SpawnPos);
}
else SendClientMessage(playerid, COLOR_LIGHTRED, "[Error]: {FFFFFF} You are not allowed to use that command!");
}
else SendClientMessage(playerid, COLOR_LIGHTRED, "[Error]: {FFFFFF} You are not logged in!");
return 1;
stock LoadSpawnPosition(const filename[])
{
new File:file_ptr;
new line[256];
new var_from_line[64];
new Float:SpawnX;
new Float:SpawnY;
new Float:SpawnZ;
new Float:SpawnA;
new index;
file_ptr = fopen(filename,filemode:io_read);
if(!file_ptr) return 0;
while(fread(file_ptr,line,256) > 0)
{
index = 0;
index = token_by_delim(line,var_from_line,',',index+1);
if(index == (-1)) continue;
SpawnX = floatstr(var_from_line);
index = token_by_delim(line,var_from_line,',',index+1);
if(index == (-1)) continue;
SpawnY = floatstr(var_from_line);
index = token_by_delim(line,var_from_line,',',index+1);
if(index == (-1)) continue;
SpawnZ = floatstr(var_from_line);
index = token_by_delim(line,var_from_line,',',index+1);
if(index == (-1)) continue;
SpawnA = floatstr(var_from_line);
for(new i = 0; i < MAX_PLAYERS; i++)
{
SetPlayerPos(i, SpawnX, SpawnY, SpawnZ);
SetPlayerFacingAngle(i, SpawnA);
}
}
fclose(file_ptr);
return 1;
}
stock token_by_delim(const string[], return_str[], delim, start_index)
{
new x=0;
while(string[start_index] != EOS && string[start_index] != delim) {
return_str[x] = string[start_index];
x++;
start_index++;
}
return_str[x] = EOS;
if(string[start_index] == EOS) start_index = (-1);
return start_index;
}
new Float:X
new Float:Y
new Float:Z
new Float:A
pawn Код:
|