10.11.2014, 10:51
(
Последний раз редактировалось Jason321; 10.11.2014 в 11:27.
)
Hi. I'm working on some modifications to -Sneaky-'s duel script. After the winner is decided, it should teleport both players back to where they originally were when they accepted/challenged the duel. It does teleport the winner back, however the loser just respawns at one of the random spawn locations set in the gamemode.
Here is where I get the player's data:
And here is where I send them back to where they were:
Now OnPlayerSpawn I try to take the player that lost/died back to where they were before they participated in the duel:
It seems to ignore the first part and just continue to the randomspawn function. I've debugged to check that wasInDuel[playerid] does in fact = 1 for that player, and it does so I'm not sure what the issue is.
In OnPlayerDeath I have it so the player that won goes back to where they were and it works:
Any help would be greatly appreciated. Thanks
Here is where I get the player's data:
pawn Код:
SetupPlayerForDuel(playerid)
{
playerWorld[playerid] = GetPlayerVirtualWorld(playerid);
playerInt[playerid] = GetPlayerInterior(playerid);
GetPlayerArmour(playerid, playerArmour[playerid]);
GetPlayerHealth(playerid, playerHP[playerid]);
GetPlayerFacingAngle(playerid, playerAngle[playerid]);
GetPlayerPos(playerid, playerX[playerid], playerY[playerid], playerZ[playerid]);
playerColour[playerid] = GetPlayerColor(playerid);
for(new w; w < 13; w++) GetPlayerWeaponData(playerid, w, guns[w][playerid], ammo[w][playerid]);
ResetPlayerWeapons(playerid);
SetPlayerVirtualWorld(playerid, 107);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 100);
GivePlayerWeapon(playerid, 26, 500);
GivePlayerWeapon(playerid, 32, 500);
wasInDuel[playerid] = 1;
SetPlayerColor(playerid, COLOR_RED);
return 1;
}
pawn Код:
StopDuelForPlayer(playerid)
{
SetPlayerVirtualWorld(playerid, playerWorld[playerid]);
SetPlayerInterior(playerid, playerInt[playerid]);
SetPlayerArmour(playerid, playerArmour[playerid]);
SetPlayerHealth(playerid, playerHP[playerid]);
SetPlayerFacingAngle(playerid, playerAngle[playerid]);
SetPlayerPos(playerid, playerX[playerid], playerY[playerid], playerZ[playerid]);
ResetPlayerWeapons(playerid);
for(new w = 0; w <= 12; w++) GivePlayerWeapon(playerid, weapons[w][0][playerid], weapons[w][1][playerid]);
wasInDuel[playerid] = 0;
SetPlayerColor(playerid, playerColour[playerid]);
return 1;
}
pawn Код:
if(wasInDuel[playerid] == 1) StopDuelForPlayer(playerid);
else SetPlayerRandomSpawn(playerid);
In OnPlayerDeath I have it so the player that won goes back to where they were and it works:
pawn Код:
if(g_IsPlayerDueling[playerid] == 1 && g_IsPlayerDueling[killerid] == 1)
{
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
GetPlayerName(killerid, zName, MAX_PLAYER_NAME);
{
format(sString, sizeof(sString),"DUEL UPDATE: %s has won the duel against %s!", zName, pName);
SendClientMessageToAll(COLOR_ORANGE, sString);
g_GotInvitedToDuel[playerid] = 0; g_HasInvitedToDuel[playerid] = 0; g_IsPlayerDueling[playerid] = 0;
g_GotInvitedToDuel[killerid] = 0; g_HasInvitedToDuel[killerid] = 0; g_IsPlayerDueling[killerid] = 0;
g_DuelInProgress = 0;
StopDuelForPlayer(killerid);
return 1;
}
}