OnPlayerDeath and OnPlayerSpawn
#1

Hello, tell me please:
I need to:
The player on cmd, teleported in coord X, y, z
After entering the command, if he died, he next three spawn in x.y.z, and so 3 times. and then as usual
Reply
#2

in english please
Reply
#3

Edit 1 Post
better?
Understand?
Reply
#4

I understand

pawn Код:
new deathcount[MAX_PLAYERS];
new SpawnPos[4][MAX_PLAYERS];

//OnPlayerCommandText
if(strcmp(cmdtext,"/command",true)==0)
{
    GetPlayerPos(playerid,SpawnPos[0][playerid],SpawnPos[1][playerid],SpawnPos[2][playerid]);
    GetPlayerFacingAngle(playerid,SpawnPos[3][playerid]);
    deathcount[playerid]=3;
    return SendClientMessage(playerid,0xFF0000FF,"You will now spawn here 3 more times.");
}

public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(newstate==PLAYER_STATE_SPAWNED)
    {
        if(deathcount[playerid]>0)
        {
            SetPlayerPos(playerid,SpawnPos[0][playerid],SpawnPos[1][playerid],SpawnPos[2][playerid]);
            SetPlayerFacingAngle(playerid,SpawnPos[3]);
            deathcount[playerid]--;
        }
    }
}
Reply
#5

This will act if the player will press a key after the command-and-death, right? or keystroke does not necessarily?
Reply
#6

SilentHuntr,
pawn Код:
#include <a_samp>
new deathcount[MAX_PLAYERS];
//new SpawnPos[4][MAX_PLAYERS];

new Float:SpawnPos[][4] =
 {
  {-2796.9854, 1224.8180, 20.5429, 192.0335},
  {-2454.2170, 503.8759, 30.0790, 267.2932},
  {-2669.7322, -6.0874, 6.1328, 89.8853}
 }
#if defined FILTERSCRIPT

public OnFilterScriptInit()
{

    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Sumo");
    print("----------------------------------\n");
}

#endif

public OnFilterScriptInit()
{

}

public OnPlayerCommandText(playerid,cmdtext[])
{
if(strcmp(cmdtext,"/cmd",true)==0)
{
GetPlayerPos(playerid,SpawnPos[0][playerid],SpawnPos[1][playerid],SpawnPos[2][playerid]);
deathcount[playerid]=3;
return SendClientMessage(playerid,0xFF0000FF,"You will now spawn here 3 more times.");
}
return 0;
}
public OnPlayerStateChange(playerid,newstate,oldstate)
{
if(newstate==PLAYER_STATE_SPAWNED)
{
if(deathcount[playerid]>0)
{
SetPlayerPos(playerid,SpawnPos[0][playerid],SpawnPos[1][playerid],SpawnPos[2][playerid]);
deathcount[playerid]--;
}
}
}
when I write /cmd, all server lag..
Reply
#7

What that does is makes the player's coordinate his new spawn spot.
Reply
#8

Sorry please ..
But I poorly understand what you said ..
Write what needs to be corrected in my code please
Reply
#9

help me please........
Reply
#10

Something like this..
pawn Код:
enum Last
{
  Float:LastX,
  Float:LastY,
  Float:LastZ,
  Float:LastA,
}
new Info[MAX_PLAYERS][Last];
new deathcount[MAX_PLAYERS];

public OnPlayerCommandText(playerid, cmdtext[])
{
  if(strcmp(cmdtext, "/command", true) == 0)
  {
   GetPlayerPos(playerid, Info[playerid][LastX], Info[playerid][LastY], Info[playerid][LastZ]);
   GetPlayerFacingAngle(playerid, Info[playerid][LastA]);
   SendClientMessage(playerid, color, "You will now spawn here 3 times!");
   deathcount[playerid] = 3;
   return 1;
  }
  return 0;
}

public OnPlayerDeath(playerid, killerid, reason)
{
  if(deathcount[playerid] > 0)
 {
   deathcount[playerid] --;
  }
  return 1;
}

public OnPlayerSpawn(playerid)
{
  if(deathcount[playerid] > 0)
  {
   SetPlayerPos(playerid, Info[playerid][LastX], Info[playerid][LastY], Info[playerid][LastZ]);
   SetPlayerFacingAngle(playerid, Info[playerid][LastA]);
  }
  return 1;
}
Reply


Forum Jump:


Users browsing this thread: