Spawn Killerid - 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: Spawn Killerid (
/showthread.php?tid=483065)
Spawn Killerid -
ZBits - 24.12.2013
Hello,
Simple problem,
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
inStunt[playerid] = 0;
if(InvitedDuel[killerid] == true)
{
new Float:healthkiller;
new namekiller[24],namedeather[24],string[500];
GetPlayerName(killerid, namekiller, 24);
GetPlayerName(playerid, namedeather, 24);
GetPlayerHealth(killerid,healthkiller);
format(string, sizeof(string), "%s has won the duel against %s by %0.0f health",namekiller,namedeather,healthkiller);
SendClientMessageToAll(0xB2E5BCAA, string);
SpawnPlayer(killerid);
InvitedDuel[killerid] = false;
InvitedDuel[playerid] = false;
IdDuel[playerid] = playerid;
IdDuel[killerid] = killerid;
UsingArena = false;
healthkiller = 0;
}
return 1;
}
This is a duel section fight, but when the killer kills, its supposed to respawn him but it doesnt. Need help on this please.
P.S When once the duel is over, it will show the message "%s has won the duel agains %s..." but the second time it wont. Help on that will be appreciated.
Re: Spawn Killerid -
Lynn - 24.12.2013
This could be inaccurate but my best assumption is because the player is not in the Request Class stage, there is no reason for it to "Spawn" him as the function has already been completed.
I'd suggest getting the players position and spawning him back to it. Like so:
I wrote this in Pastebin, since I don't have Pawn on this computer so it may be slightly inaccurate.
pawn Код:
enum SpawnInfo
{
Float:s_X,
Float:s_Y,
Float:s_Z,
Float:s_A,
s_VW,
s_Int
}
new S_Info[MAX_PLAYERS][SpawnInfo];
// When both players accept the duel:
GetPlayerPos(playerid, S_Info[playerid][s_X], S_Info[playerid][s_Y], S_Info[playerid][s_Z]);
GetPlayerFacingAngel(playerid, S_Info[playerid][s_A]);
GetPlayerVirtualWorld(playerid, S_Info[playerid][s_VW]);
GetPlayerInterior(playerid, S_Info[playerid][s_Int]);
// Do the above for the Other ID As-well
public OnPlayerDeath(playerid, killerid, reason)
{
inStunt[playerid] = 0;
if(InvitedDuel[killerid] == true)
{
new Float:healthkiller;
new namekiller[24],namedeather[24],string[500];
GetPlayerName(killerid, namekiller, 24);
GetPlayerName(playerid, namedeather, 24);
GetPlayerHealth(killerid,healthkiller);
format(string, sizeof(string), "%s has won the duel against %s by %0.0f health",namekiller,namedeather,healthkiller);
SendClientMessageToAll(0xB2E5BCAA, string);
SetPlayerPos(killerid, S_Info[killerid][s_X], S_Info[killerid][s_Y], S_Info[killerid][s_Z]);
SetPlayerFacingAngel(killerid, S_Info[killerid][s_A]);
SetPlayerVirtualWorld(killerid, S_Info[killerid][s_VW]);
SetPlayerInterior(killerid, S_Info[killerid][s_Int]);
InvitedDuel[killerid] = false;
InvitedDuel[playerid] = false;
IdDuel[playerid] = playerid;
IdDuel[killerid] = killerid;
UsingArena = false;
healthkiller = 0;
}
return 1;
}
Re: Spawn Killerid -
Konstantinos - 24.12.2013
Check whether the killerid is a valid player before using it in arrays because you're going to have problems with runtime error: Index out of bounds and it will most likely make the callback not to work correctly (and basically stops).
Take a look at the notes at the bottom:
https://sampwiki.blast.hk/wiki/OnPlayerDeath
Re: Spawn Killerid -
ZBits - 25.12.2013
Quote:
Originally Posted by Lynn
This could be inaccurate but my best assumption is because the player is not in the Request Class stage, there is no reason for it to "Spawn" him as the function has already been completed.
I'd suggest getting the players position and spawning him back to it. Like so:
I wrote this in Pastebin, since I don't have Pawn on this computer so it may be slightly inaccurate.
pawn Код:
enum SpawnInfo { Float:s_X, Float:s_Y, Float:s_Z, Float:s_A, s_VW, s_Int } new S_Info[MAX_PLAYERS][SpawnInfo];
// When both players accept the duel: GetPlayerPos(playerid, S_Info[playerid][s_X], S_Info[playerid][s_Y], S_Info[playerid][s_Z]); GetPlayerFacingAngel(playerid, S_Info[playerid][s_A]); GetPlayerVirtualWorld(playerid, S_Info[playerid][s_VW]); GetPlayerInterior(playerid, S_Info[playerid][s_Int]); // Do the above for the Other ID As-well
public OnPlayerDeath(playerid, killerid, reason) { inStunt[playerid] = 0; if(InvitedDuel[killerid] == true) { new Float:healthkiller; new namekiller[24],namedeather[24],string[500]; GetPlayerName(killerid, namekiller, 24); GetPlayerName(playerid, namedeather, 24); GetPlayerHealth(killerid,healthkiller); format(string, sizeof(string), "%s has won the duel against %s by %0.0f health",namekiller,namedeather,healthkiller); SendClientMessageToAll(0xB2E5BCAA, string); SetPlayerPos(killerid, S_Info[killerid][s_X], S_Info[killerid][s_Y], S_Info[killerid][s_Z]); SetPlayerFacingAngel(killerid, S_Info[killerid][s_A]); SetPlayerVirtualWorld(killerid, S_Info[killerid][s_VW]); SetPlayerInterior(killerid, S_Info[killerid][s_Int]); InvitedDuel[killerid] = false; InvitedDuel[playerid] = false; IdDuel[playerid] = playerid; IdDuel[killerid] = killerid; UsingArena = false; healthkiller = 0; } return 1; }
|
This does not work evetually.
Re: Spawn Killerid -
ZBits - 25.12.2013
removed.
Re: Spawn Killerid -
ZBits - 25.12.2013
Bump
Re: Spawn Killerid -
ZBits - 26.12.2013
Anyone?
Re: Spawn Killerid -
ZBits - 31.12.2013
Bump still need help!