OnPlayerDeath Help -
semaj - 17.06.2013
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;
return 1;
}
Hello folks am having trouble here.
What i want to do is when a player die's he is spawned at 1 of the 2 hospitals in Los Santos with a deduction of $200 and a 5 min timer to wait or is he wishes to sign him/her self out with a $500 charge
Can anyone help with this please?
Re: OnPlayerDeath Help -
Guest123 - 17.06.2013
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(PlayerInfo[playerid][pDeaths] == 1;
{
//code here SetPlayerPos(playerid,x,y,z);
}
return 1;
}
and i have one more
pawn Код:
new PlayerWasKilled[MAX_PLAYERS];
public OnPlayerDeath(playerid, killerid, reason)
{
PlayerWasKilled[playerid] = 1;
return 1;
}
public OnPlayerSpawn(playerid)
{
if(PlayerWasKilled[playerid] == 1;
{
//code here SetPlayerPos(playerid,x,y,z);
}
return 1;
}
//code for release
CMD:releaseme(playerid,params[])
{
PlayerWasKilled[playerid] = 0;
return 1;
}
sorry if i was wrong
Re: OnPlayerDeath Help -
-=Dar[K]Lord=- - 17.06.2013
pawn Код:
new Float:HopitalSpawns[][] =
{
{/*X,Y,Z,Angle Of First Hospital 1*/},
{/*X,Y,Z,Angle of second Hospital 2*/}
};
public OnPlayerDeath(playerid, killerid, reason)
{
new HostpitalSpawn = random(sizeof(HopitalSpawns));
SetPlayerPos(playerid, HostpitalSpawns[HostpitalSpawn][0], HostpitalSpawns[HostpitalSpawn][1], HostpitalSpawns[HostpitalSpawn][2]);
SetPlayerFacingAngle(playerid,HostpitalSpawns[HostpitalSpawn][3]);
return 1;
}
Re: OnPlayerDeath Help -
jakejohnsonusa - 17.06.2013
Do you know how to script in SA-MP yet?
If you are new to scripting, here are some useful links:
https://sampwiki.blast.hk/wiki/SetPlayerPos <- To set a players position in a hospital.
https://sampwiki.blast.hk/wiki/SetPlayerInterior <- To set a players interior to the hospital interior.'
https://sampwiki.blast.hk/wiki/GivePlayerMoney <- To remove a players money ($200 / $500)
https://sampwiki.blast.hk/wiki/Random <- To create the random hospital system.
So for a more infromation, as this may not help you enough:
pawn Код:
new IsInAHospital[MAX_PLAYERS];// Add this to the top of your Gamemode with the other new's.
public OnPlayerDeath(playerid, killerid, reason)
{
PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;
new rand = random(2)//This sets the random possibilities
switch(rand)//This detects what the random outcome was of the above function.
{
case 0: //Hospital spawn #1
{
SetPlayerInterior(playerid, #) //You will need to replace the # with the hospitals actual interior number.
SetPlayerPos(playerid, x_value_here, y_value_here, z_value_here)//Again, replace the xyz_value_here's with the correct ones.
IsInAHospital[playerid] = 1; //The script now knows they are in a hospital
GivePlayerMoney(playerid, -200);// This will take $200 from the player when they arrive at the hospital.
SendClientMessage(playerid, COLOR_GREEN, "You have been billed $200 for the medical fee's.");
SendClientMessage(playerid, COLOR_GREEN, "You may use the command /instaheal to pay $500 and exit now, or you may way 5 minutes to be healed.");// Message sent to the player's textbox.
}
case 1: //Hospital spawn #2
{
SetPlayerInterior(playerid, #) //You will need to replace the # with the hospitals actual interior number.
SetPlayerPos(playerid, x_value_here, y_value_here, z_value_here)//Again, replace the xyz_value_here's with the correct ones.
IsInAHospital[playerid] = 1; //The script now knows they are in a hospital
GivePlayerMoney(playerid, -200);// This will take $200 from the player when they arrive at the hospital.
SendClientMessage(playerid, COLOR_GREEN, "You have been billed $200 for the medical fee's.");
SendClientMessage(playerid, COLOR_GREEN, "You may use the command /instaheal to pay $500 and exit now, or you may way 5 minutes to be healed.");// Message sent to the player's text box.
}
}
return 1;// This means that it will stop the code, meaning it should be at the end.
}
//Now for the command /instaheal
public OnPlayerCommandText(playerid, cmdtext[])// Detects commands (you probably have this in your GM)
{
if (strcmp("/instaheal", cmdtext, true, 10) == 0)//The command to create
{
if(IsInAHospital[playerid] != 1)
{
IsInAHospital[playerid] = 0; //Ensure's they aren't in a hospital
SendClientMessage(playerid, COLOR_GREEN, "You aren't in a hospital to use this command!.");
return 1;
}
SendClientMessage(playerid, COLOR_GREEN, "You have made a full recovery.");
SendClientMessage(playerid, COLOR_GREEN, "You have been billed $500 for the extensive fast treatment."); //Message sent to the player's textbox.
SetPlayerInterior(playerid, 0)
SetPlayerPos(playerid, x_value_here, y_value_here, z_value_here)//Again, replace the xyz_value_here's with the correct ones.
GivePlayerMoney(playerid, -500);// This will take $500 from the player when they exit the hospital.
}
return 1;// This means that it will stop the code, meaning it should be at the end.
}
//Also add this to be safe
public OnPlayerDisconnect(playerid, reason)
{
IsInAHospital[playerid] = 0; //reset's the hospital value to 0. Just in case they were in one when they exited the server.
return 1;
}