SA-MP Forums Archive
respawn command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: respawn command (/showthread.php?tid=649783)



respawn command - ivndosos - 15.02.2018

I have my respawn command, It works good and all, but how do I make it to respawn nearby players? ( Not too nearby, but with a little distance as I would say something about from binco to grove street distance! )

Код:
CMD:respawn(playerid, params[])
{
   if(connected[playerid] == true) return GameTextForPlayer(playerid, "~r~Spawn First", 5000, 5);
   if(GetPVarInt(playerid,"CMDABUSE")>GetTickCount())return SendClientMessage(playerid,-1,"{c3c3c3}(INFO) You need to wait 10 seconds before using /respawn again!");
   Killed[playerid] = 0;
   SetPVarInt(playerid,"CMDABUSE",GetTickCount()+10000); // anti abuse measurements
   new interiorID = GetPlayerInterior(playerid);
   new Float:health;
   GetPlayerHealth(playerid,health);
   if(interiorID == 10) return SendClientMessage(playerid, -1, "{c3c3c3}You can't use /respawn while in lobby, type /back first!"); // checking if player is in /lobby before typing /respawn
   if(health > 90)
   {
        SpawnPlayer(playerid);
        SendClientMessage(playerid, -1, "{c3c3c3}(INFO) You have respawned!");
        PlayerTotalKills[playerid] = 0;
        Killed[playerid] = 0;
   }
   else
   {
      SendClientMessage(playerid, -1, "{c3c3c3}(INFO) Atleast 90hp is required in order to respawn.");
   }
   return 1;
}



Re: respawn command - RogueDrifter - 15.02.2018

loop through all players and get the position of the player who made the cmd then check if any player is in range of that point and make sure you mark out the player who made the cmd (i != playerid)


Re: respawn command - PepsiCola23 - 15.02.2018

PHP код:
new range;
if(
sscanf(params"i"range)) return SCM(...
foreach(
Playeri)
    {
        if(
IsPlayerConnected(i))
        {
            if(
GetDistanceBetweenPlayers(playeridi) < range)
            {
                ....
                
            }
        }
    } 



Re: respawn command - ivndosos - 15.02.2018

I don't understand, Can you put a little more detail with some explanation?


Re: respawn command - RogueDrifter - 15.02.2018

PHP код:
CMD:respawnplayers(playeridparams[])
{
    new 
Float:xFloat:yFloat:z;
    
GetPlayerPos(playeridxyz);//get pos of the player doing the cmd

    
for(new iGetPlayerPoolSize(); <= ji++)//loop through all players
    
{
        if(
IsPlayerInRangeOfPoint(i10.0xyz) && != playerid)//check if any player is in range of the player who did the command and that player is not the command issuer.
        
{
            
SpawnPlayer(i);//spawn him
//etc code 



Re: respawn command - ivndosos - 15.02.2018

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
PHP код:
CMD:respawnplayers(playeridparams[])
{
    new 
Float:xFloat:yFloat:z;
    
GetPlayerPos(playeridxyz);//get pos of the player doing the cmd
    
for(new iGetPlayerPoolSize(); <= ji++)//loop through all players
    
{
        if(
IsPlayerInRangeOfPoint(i10.0xyz) && != playerid)//check if any player is in range of the player who did the command and that player is not the command issuer.
        
{
            
SpawnPlayer(i);//spawn him
//etc code 
So it should look somewhere like that?

Код:
CMD:respawn(playerid, params[])
{
   if(connected[playerid] == true) return GameTextForPlayer(playerid, "~r~Spawn First", 5000, 5);
   if(GetPVarInt(playerid,"CMDABUSE")>GetTickCount())return SendClientMessage(playerid,-1,"{c3c3c3}(INFO) You need to wait 5 seconds before using /respawn again!");
   Killed[playerid] = 0;
   SetPVarInt(playerid,"CMDABUSE",GetTickCount()+5000); // anti abuse measurements
   new Float:x, Float:y, Float:z;
   GetPlayerPos(playerid, x, y, z);//get pos of the player doing the cmd
    for(new i, j = GetPlayerPoolSize(); i <= j; i++)//loop through all players
    {
        if(IsPlayerInRangeOfPoint(i, 10.0, x, y, z) && i != playerid)
        {
            SpawnPlayer(i);//spawn him
		}
	 }
   new interiorID = GetPlayerInterior(playerid);
   new Float:health;
   GetPlayerHealth(playerid,health);
   if(interiorID == 10) return SendClientMessage(playerid, -1, "{c3c3c3}You can't use /respawn while in lobby, type /back first!");
   if(health > 90)
   {
        SpawnPlayer(playerid);
        SendClientMessage(playerid, -1, "{c3c3c3}(INFO) You have respawned!");
        PlayerTotalKills[playerid] = 0;
        Killed[playerid] = 0;
   }
   else
   {
      SendClientMessage(playerid, -1, "{c3c3c3}(INFO) Atleast 90hp is required in order to respawn.");
   }
   return 1;
}



Re: respawn command - Mugala - 15.02.2018

Quote:
Originally Posted by ivndosos
Посмотреть сообщение
So it should look somewhere like that?

Код:
CMD:respawn(playerid, params[])
{
   if(connected[playerid] == true) return GameTextForPlayer(playerid, "~r~Spawn First", 5000, 5);
   if(GetPVarInt(playerid,"CMDABUSE")>GetTickCount())return SendClientMessage(playerid,-1,"{c3c3c3}(INFO) You need to wait 5 seconds before using /respawn again!");
   Killed[playerid] = 0;
   SetPVarInt(playerid,"CMDABUSE",GetTickCount()+5000); // anti abuse measurements
   new Float:x, Float:y, Float:z;
   GetPlayerPos(playerid, x, y, z);//get pos of the player doing the cmd
    for(new i, j = GetPlayerPoolSize(); i <= j; i++)//loop through all players
    {
        if(IsPlayerInRangeOfPoint(i, 10.0, x, y, z) && i != playerid)
        {
            SpawnPlayer(i);//spawn him
		}
	 }
   new interiorID = GetPlayerInterior(playerid);
   new Float:health;
   GetPlayerHealth(playerid,health);
   if(interiorID == 10) return SendClientMessage(playerid, -1, "{c3c3c3}You can't use /respawn while in lobby, type /back first!");
   if(health > 90)
   {
        SpawnPlayer(playerid);
        SendClientMessage(playerid, -1, "{c3c3c3}(INFO) You have respawned!");
        PlayerTotalKills[playerid] = 0;
        Killed[playerid] = 0;
   }
   else
   {
      SendClientMessage(playerid, -1, "{c3c3c3}(INFO) Atleast 90hp is required in order to respawn.");
   }
   return 1;
}
no u placed it in wrong place (player must be respawned first with SpawnPlayer)
also when u find a position of nearby players (with looping) you must set a player's position at nearby player by adding and removing X,Y positions randomly, after that, you have to find Z cord and set player's position at these randomly generated X,Y,Z.


Re: respawn command - ivndosos - 19.02.2018

hi im still having issues


Re: respawn command - ivndosos - 09.03.2018

bump


Re: respawn command - KayJ - 09.03.2018

What's the issue now?