26.10.2011, 08:13
Hi there!
I'm working on a RP gamemode, and i have a little (funny) bug. When a player dies, he is teleported to the LS Hospital. If you check the place where the player died, it always spawns a beer bottle or cigar there in the ground. Here's my code with OnPlayerDeath and OnPlayerSpawn.
The DeathHandler in the callback is just a pointer to the function below.
The Player skin is set in the OnPlayerSpawn callback, which is:
Hope anyone knows what the problem/bug is.
I'm working on a RP gamemode, and i have a little (funny) bug. When a player dies, he is teleported to the LS Hospital. If you check the place where the player died, it always spawns a beer bottle or cigar there in the ground. Here's my code with OnPlayerDeath and OnPlayerSpawn.
Код:
public OnPlayerDeath(playerid, killerid, reason) { tPlayerStats_DeathHandler(playerid, killerid, reason); return 1; }
Код:
tPlayerStats_DeathHandler(playerid, killerid, reason) { // Player has died, hide the speedometer in case the player was driving for(new i; i < 4; i++) TextDrawHideForPlayer(playerid, TextDrawsd[playerid][i]); for(new i; i < 15; i++) TextDrawHideForPlayer(playerid, TextDraws[TDSpeedClock][i]); SendClientMessage(playerid, COLOR_RED, "Oh no! You passed out! You've been taken to hospital by Ambulance!"); new adminstring[512], deadplayer[MAX_PLAYER_NAME], killername[MAX_PLAYER_NAME]; GetPlayerName(playerid, deadplayer, sizeof(deadplayer)); if(killerid != INVALID_PLAYER_ID) { GetPlayerName(killerid, killername, sizeof(killername)); format(adminstring,sizeof(adminstring),"[DEATH] %s(%i) >>> %s(%i) >>> %s", deadplayer, playerid, killername, killerid, DeathReason[reason]); } else { format(adminstring,sizeof(adminstring),"[DEATH] %s(%i) >>> %s", deadplayer, playerid, DeathReason[reason]); } tChat_AdminMsg(COLOR_LIGHTBLUE, adminstring); SendDeathMessage(killerid, playerid, reason); PlayerInfo[playerid][Dead] = 1; SetSpawnInfo(playerid, 0, 0, 1200.85, -1338.408, 15, 0, 0, 0, 0, 0, 0, 0); return 1; }
Код:
public OnPlayerSpawn(playerid) { new IsPlayerDead; IsPlayerDead = PlayerInfo[playerid][Dead]; if(IsPlayerDead) { SetPlayerSkin(playerid, PlayerInfo[playerid][Skin]); PlayerInfo[playerid][Dead] = 0; GivePlayerMoney(playerid, 100); } return 1; }