25.10.2009, 16:37
Hi,
I've got this annoying problem somehow. Basically when a player dies, he dies, but he doesn't respawn. The camera just stays as it is (because i use setcamerapos - thats fine), the health bar remains flashing, but i can move about. I've noticed that when i set my health to 100 it respawns me and OnPlayerSpawn is called, otherwise OnPlayerSpawn is not called.
Here's my OnPlayerDeath callback:
If you want to see OnPlayerSpawn please let me know, but at the moment i dont think it's necessary. I've also noticed that On foot rate, incar_rate etc is not set in my server.cfg, is this a problem? (BTW, i'm using 0.3).
Any help would be appreciated. I've disabled all my FS's etc and the problem still remains. Someone has suggested to use timers on irc, but i'd rather not cure it, but rather prevent it in the first place.
Thanks.
I've got this annoying problem somehow. Basically when a player dies, he dies, but he doesn't respawn. The camera just stays as it is (because i use setcamerapos - thats fine), the health bar remains flashing, but i can move about. I've noticed that when i set my health to 100 it respawns me and OnPlayerSpawn is called, otherwise OnPlayerSpawn is not called.
Here's my OnPlayerDeath callback:
pawn Код:
public OnPlayerDeath(playerid,killerid,reason)
{
new dbugstring[128];
format(dbugstring,sizeof(dbugstring),"|| DEBUG || %s Onplayerdeathstarted", playerid);
SendClientMessageToAll(COLOR_BRIGHTRED,dbugstring);
print(dbugstring);
TextDrawShowForPlayer(playerid,WideScreenUp);
TextDrawShowForPlayer(playerid,WideScreenDown);
format(dbugstring,sizeof(dbugstring),"|| DEBUG || %s BAR TD SHOWN", playerid);
SendClientMessageToAll(COLOR_BRIGHTRED,dbugstring);
print(dbugstring);
//GameTextForPlayer(playerid,"Wasted", 3000, 2);
new Float:X, Float:Y, Float:Z; //creating some variables
GetPlayerPos(playerid, X, Y, Z);
SetPlayerCameraPos(playerid, X + 22.0, Y + 5.0, Z + 15.0);
SetPlayerCameraLookAt(playerid, X, Y, Z);
format(dbugstring,sizeof(dbugstring),"|| DEBUG || %s CAMERa SET", playerid);
SendClientMessageToAll(COLOR_BRIGHTRED,dbugstring);
print(dbugstring);
SetPlayerWorldBounds(playerid, INFINITY, -INFINITY, INFINITY, -INFINITY);
if(GAMETYPE == 2 && Current != -1 && Player[playerid][pPlaying]) // for TDM
{
Player[playerid][pPlaying] = true;
if(Player[killerid][pTeam] == T_ATT) TDM_DEFScore++;
else if(Player[killerid][pTeam] == T_DEF) TDM_ATTScore++;
}
else Player[playerid][pPlaying] = false;
ViewingBase[playerid] = -1;
SendDeathMessage(killerid,playerid,reason);
ResetPlayerWeapons(playerid);
GivePlayerMoney(playerid, 100);
SetPlayerTeam(playerid,playerid);
TextDrawShowForAll(Baseloading);
GivePlayerMoney(playerid, 100);
if(IsPlayerConnected(killerid)) SetPlayerScore(killerid, GetPlayerScore(killerid) + 1); /// This updates player's score when he kills someone
if(KillsCountActive)
{
Kills[killerid]++;
}
format(dbugstring,sizeof(dbugstring),"|| DEBUG || %s STAGE 3", playerid);
SendClientMessageToAll(COLOR_BRIGHTRED,dbugstring);
print(dbugstring);
if(KillzCounter && IsPlayerConnected(killerid) && Player[killerid][pPlaying] == true) Killz[killerid]++;
for(new x=0; x<MAX_SERVER_PLAYERS; x++) {
if(GetPlayerState(x) == PLAYER_STATE_SPECTATING && gSpectateID[x] == playerid) {
StopSpectate(x);
}
}
if(reason == 50)
{
new killername[24],string[STR];
GetPlayerName(killerid,killername,STR);
format(string,STR,"%s has been eliminated for Heli-Killing.",killername);
SendClientMessageToAll(COLOR_BRIGHTRED,string);
SetPlayerHealth(killerid,0);
}
if(reason == 4)
{
new killername[MAX_PLAYER_NAME],playername[MAX_PLAYER_NAME], string[STR], string2[STR];
GetPlayerName(killerid,killername,STR), GetPlayerName(playerid,playername,sizeof(playername));
format(string,STR,"|| Knifage!! || %s has Knifed %s to death in the back!",killername, playername);
SendClientMessageToAll(COLOR_BRIGHTRED,string);
format(string2,STR,"Smart kill there %s, have $250 for killing %s",killername, playername);
SendClientMessage(killerid,COLOR_GREY,string2);
GivePlayerMoney(killerid, 250);
}
if(IsPlayerInCheckpoint(playerid))
{
KillTimer(CountdownTimer);
IsCPTimerStarted=0;
KillTimer(CTime);
}
for(new x=0; x<MAX_SERVER_PLAYERS; x++)
{
if(GetPlayerState(x) == PLAYER_STATE_SPECTATING && gSpectateID[x] == playerid)
{
AdvanceSpectate(x);
}
}
if(!Player[playerid][killedhimself] && killerid != INVALID_PLAYER_ID)
{
new killer[MAX_PLAYER_NAME], killmsg[128];
new Float:armour, Float:health2;
GetPlayerHealth(killerid, health2);
GetPlayerArmour(killerid, armour);
GetPlayerName(killerid,killer,sizeof(killer));
format(killmsg, sizeof(killmsg), "Your killer %s had %.0f health points and %.0f armour.", killer, health2, armour);
SendClientMessage(playerid, AAD_COLOR_RED, killmsg);
TogglePlayerSpectating(playerid, 1);
PlayerSpectatePlayer(playerid, killerid);
SendClientMessage(playerid,COLOR_LIME,">> Respawning in 5 seconds...");
SetTimerEx("STOPSPECCINGNOW", 5000, false, "d", playerid);
}
if(Player[playerid][pPlaying]== true && FirstRoundKill)
{
GameTextForAll("~r~~n~~n~~n~~n~First Blood",5000,3);
FirstRoundKill = false;
}
format(dbugstring,sizeof(dbugstring),"|| DEBUG || %s Onplayerdeath ENDED", playerid);
SendClientMessageToAll(COLOR_BRIGHTRED,dbugstring);
print(dbugstring);
return 1;
}
Any help would be appreciated. I've disabled all my FS's etc and the problem still remains. Someone has suggested to use timers on irc, but i'd rather not cure it, but rather prevent it in the first place.
Thanks.