SA-MP Forums Archive
Need some help with on player death!! - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Need some help with on player death!! (/showthread.php?tid=107117)



Need some help with on player death!! - Globe2009 - 08.11.2009

i have a small problem
im making a new script with comptons starter kit

and as soon as i die it teles me to hospital i stand there for 1 second then die properly and spawn again where i spawn when i join the game(login)

what do i do so i stay at the hospital?

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
  SetPlayerPos(playerid, 1178.1852,-1323.3883,14.1076);
  SendClientMessage(playerid, COLOR_PINK, "YOU GOT ****** UP");
  GivePlayerMoney(playerid, -20);
  return 1;
}



Re: Need some help with on player death!! - Globe2009 - 08.11.2009

an does anyone know how to edit gl_property?
i been looking all morning cant find the answer anywhere


Re: Need some help with on player death!! - bajskorv123 - 08.11.2009

Try this Hope it helped, im not a very good scripter
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
  SendClientMessage(playerid, COLOR_PINK, "YOU GOT ****** UP");
  GivePlayerMoney(playerid,-20);
  return 1;
}

public OnPlayerSpawn(playerid)
{
  SetPlayerPos(playerid, 1178.1852,-1323.3883,14.1076);
  return 1;
}



Re: Need some help with on player death!! - Globe2009 - 08.11.2009

well it works but now i spawn outside the hospital when i login lol
thanks alot for the replying dude i didnt think i was gona get an answer


Re: Need some help with on player death!! - Globe2009 - 08.11.2009

ok gona try and make it easier for ya
Quote:

//================================================== ================================================== ========
// OnPlayerSpawn
//================================================== ================================================== ========
// This is when a player picks his character and spawns at a location!
// You Can Like Right Now COpy The SendClientMessage you did there, IF you want.
public OnPlayerSpawn(playerid)
{
SendClientMessage(playerid, COLOR_GREEN, "Here's The Key's To A RentCar Just Take One");
SpawnPlayerAtHouse(playerid);
SetPlayerPos(playerid, 1178.5691,-1323.4521,14.1265);
return 1;
}
//================================================== ================================================== ========
// OnPlayerDeath
//================================================== ================================================== ========
// ok this is when a player dies and shit. if you want to you can make a player lose money when they die if
// You Want that just delete the // before the Giveplayermoney
// Edit the 50 to determine how much he/she loses if you want the killer to get money change Playerid to Killerid next to
// Giveplayermoney
public OnPlayerDeath(playerid, killerid, reason)
{
SetPlayerHealth(playerid, 100.0);
SetPlayerInterior(playerid, 0);
SetPlayerFacingAngle(playerid, 0);
GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~w~You Got Fucked Up", 10000, 1);
PlayerPlaySound(playerid, 1062, 0.0, 0.0, 0.0);
SetPlayerPos(playerid, 1182.5638,-1323.5256,13.5790);
return 1;
}

but when you choose a skin class it already has coords so when you choose it you spawn there..
Quote:

AddPlayerClass(158,1642.6589,-2239.5496,13.4958,180.2199,0,0,0,0,0,0); //civil skin
AddPlayerClass(160,1642.6589,-2239.5496,13.4958,180.2199,0,0,0,0,0,0); //civil skin
AddPlayerClass(204,1642.6589,-2239.5496,13.4958,180.2199,0,0,0,0,0,0); //civil skin
AddPlayerClass(249,1642.6589,-2239.5496,13.4958,180.2199,0,0,0,0,0,0); //civil skin
AddPlayerClass(264,1642.6589,-2239.5496,13.4958,180.2199,0,0,0,0,0,0); //civil skin
AddPlayerClass(269,1642.6589,-2239.5496,13.4958,180.2199,0,0,0,0,0,0); //civil skin
AddPlayerClass(270,1642.6589,-2239.5496,13.4958,180.2199,0,0,0,0,0,0); //civil skin
AddPlayerClass(271,1642.6589,-2239.5496,13.4958,180.2199,0,0,0,0,0,0); //civil skin
AddPlayerClass(141,1642.6589,-2239.5496,13.4958,180.2199,0,0,0,0,0,0); //civil skin

hmmm lol sorry guys
onplayerdeath looks abit messy cause the quote dont like it its not really that bad


Re: Need some help with on player death!! - retart441 - 08.11.2009

If you want it so that when a player dies they spawn some were different then if they like log in, or change there skin or something.

Код:
new Died[MAX_PLAYERS];
under on player death
Код:
Died[playerid] = 1;
OnPlayerSpawn
Код:
if(Died[playerid] == 1)
{
SetPlayerPos(playerid, // Cords you want );
SendClientMessage(playerid, COLOR, "Text");
Died[playerid] = 0;
return 1;
}
Anything that you don't want to happen when the player dies, like spawn at house, or maybe other text, should stay outside the if statement.

Edit: PMEd this to you, incase you miss the post.


Re: Need some help with on player death!! - Globe2009 - 08.11.2009

na didnt work mate but if you wana look here it is

http://pastebin.ca/1662205


Re: Need some help with on player death!! - retart441 - 08.11.2009

Код:
new Died[MAX_PLAYERS];
Код:
public OnPlayerSpawn(playerid)
{
  SendClientMessage(playerid, COLOR_GREEN, "Here's The Key's To A RentCar Just Take One");
  SpawnPlayerAtHouse(playerid);
  SetPlayerPos(playerid, 1178.5691,-1323.4521,14.1265);
  if(Died[playerid] == 1)
  {
  SetPlayerInterior(playerid, 0); // In case they died in an Interior
  SetPlayerFacingAngle(playerid, 0);
  SetPlayerPos(playerid, 1182.5638,-1323.5256,13.5790);
  GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~w~You Got Fucked Up", 10000, 1);
  Died[playerid] = 0; 
  return 1;
  }
  return 1;
}

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
  Died[playerid] = 1;
  PlayerPlaySound(playerid, 1062, 0.0, 0.0, 0.0);
  return 1;
            }

That should work, I edited it with the cords in your paste bin.





Re: Need some help with on player death!! - Globe2009 - 08.11.2009

i did try bud but it does same as before an it just keeps spawning me at the hospital
nvm dude thanks alot for you're help though man.. im just gona give it up lol


Re: Need some help with on player death!! - Josipx - 08.11.2009

Try this:
Код:
//On top of the script
enum player_enum
{
	bool:dead
}
new player[MAX_PLAYER_NAME][player_enum];

//OnPlayerDeath
public OnPlayerDeath(playerid, killerid, reason)
{
	player[playerid][dead] = true;
	return 1;
}

//OnPlayerSpawn
public OnPlayerSpawn(playerid)
{
	if (player[playerid][dead]) {
	  SetPlayerPos(playerid,1178.1852,-1323.3883,14.1076);
      SendClientMessage(playerid, COLOR_PINK, "YOU GOT ****** UP");
      GivePlayerMoney(playerid, -20);
	}
	return 1;
}
That should work