Hallo,
ich bin gerade dabei ein Wiederbelebungssystem zu machen. Also, so funktioniert das ganze:
Der Spieler stirbt und wird durch SetPlayerHealth auf unendlich HP sofort wieder respawnt. So wird die eigentliche Sterbeanimation "unterbunden". Wenn der Spieler also wieder unmittelbar gespawnt ist, lass ich ihn nochmal die Sterbeanimation durchführen. Das erlaubt es mir den Spieler liegen zu lassen, ohne, dass er gezwungenermaßen respawnt wird. Während ein Spieler also im "Downstate" ist, verblutet er. Andere Spieler können zum angeschlagenen Spieler hin und ihn wiederbeleben. Die verbleibende Lebensdauer wird mit BleedOutPoints festgelegt, die beim Verbluten stetig sinken, oder eben beim Wiederbeleben steigen.
Quellcode zur Include
new BleedOutPoints[MAX_PLAYERS] = 30;
new bool:BeingRezzed[MAX_PLAYERS] = false;
new bool:Rezzing[MAX_PLAYERS] = false;
new PlayersRezzingPlayer[MAX_PLAYERS];
new Text3D:RezzLabel[MAX_PLAYERS];
{
RezzLabel[playerid] = CreateDynamic3DTextLabel("", C_RED, pDeathLoc[playerid][0], pDeathLoc[playerid][1], pDeathLoc[playerid][2], 100.0, playerid, INVALID_VEHICLE_ID, 0, 0, -1, -1, 100.0);
BleedOutTimer[playerid] = SetTimerEx("BleedOut", 1000, true, "i", playerid);
switch(pInfo[playerid][Language])
{
case LANGUAGE_DE: GameTextForPlayer(playerid, "30~n~~n~Druecke ~r~~k~~KEY_SECONDARY_ATTACK~~w~ um zu respawnen!", 1000, 5);
case LANGUAGE_EN: GameTextForPlayer(playerid, "30~n~~n~Press ~r~~k~~KEY_SECONDARY_ATTACK~~w~ to respawn!", 1000, 5);
}
return BO_OnPlayerDeath(playerid, killerid, reason);
}
#if defined _ALS_OnPlayerDeath
#undef OnPlayerDeath
#else
#define _ALS_OnPlayerDeath
#endif
#define OnPlayerDeath BO_OnPlayerDeath
public BleedOut(playerid)
{
if(!BeingRezzed[playerid])
{
BleedOutPoints[playerid]--;
new string3D[3],
stringGT[64];
format(string3D, sizeof(string3D), "%d", BleedOutPoints[playerid]);
UpdateDynamic3DTextLabelText(RezzLabel[playerid], C_RED, string3D);
switch(pInfo[playerid][Language])
{
case LANGUAGE_DE: format(stringGT, sizeof(stringGT), "%d~n~~n~Druecke ~r~~k~~KEY_SECONDARY_ATTACK~~w~ um zu respawnen!", BleedOutPoints[playerid]);
case LANGUAGE_EN: format(stringGT, sizeof(stringGT), "%d~n~~n~Press ~r~~k~~KEY_SECONDARY_ATTACK~~w~ to respawn!", BleedOutPoints[playerid]);
}
GameTextForPlayer(playerid, stringGT, 1000, 5);
}
if(BeingRezzed[playerid])
{
BleedOutPoints[playerid] += (2*PlayersRezzingPlayer[playerid]);
new string3D[3],
stringGT[64];
format(string3D, sizeof(string3D), "%d", BleedOutPoints[playerid]);
UpdateDynamic3DTextLabelText(RezzLabel[playerid], C_RED, string3D);
switch(pInfo[playerid][Language])
{
case LANGUAGE_DE: format(stringGT, sizeof(stringGT), "%d~n~~n~Druecke ~r~~k~~KEY_SECONDARY_ATTACK~~w~ um zu respawnen!", BleedOutPoints[playerid]);
case LANGUAGE_EN: format(stringGT, sizeof(stringGT), "%d~n~~n~Press ~r~~k~~KEY_SECONDARY_ATTACK~~w~ to respawn!", BleedOutPoints[playerid]);
}
GameTextForPlayer(playerid, stringGT, 1000, 5);
}
if(BleedOutPoints[playerid] <= 0)
{
new stringGT[14];
switch(pInfo[playerid][Language])
{
case LANGUAGE_DE: format(stringGT, sizeof(stringGT), "Verblutet");
case LANGUAGE_EN: format(stringGT, sizeof(stringGT), "Bled to death");
}
GameTextForPlayer(playerid, stringGT, 3000, 5);
KillTimer(BleedOutTimer[playerid]);
DestroyDynamic3DTextLabel(RezzLabel[playerid]);
BleedOutPoints[playerid] = 30;
cmd_respawn(playerid, "");
}
if(BleedOutPoints[playerid] >= 100)
{
SetPlayerPos(playerid, pDeathLoc[playerid][0], pDeathLoc[playerid][1], pDeathLoc[playerid][2]);
SetPlayerFacingAngle(playerid, pDeathLoc[playerid][3]);
KillTimer(BleedOutTimer[playerid]);
DestroyDynamic3DTextLabel(RezzLabel[playerid]);
BleedOutPoints[playerid] = 30;
}
return 1;
}
{
if(newkeys & KEY_CTRL_BACK) //H
{
new closestID = GetClosestPlayer(playerid, 1.0);
if(IsPlayerDead[closestID])
{
if(!Rezzing[playerid] && GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
{
PlayersRezzingPlayer[closestID]++;
SetPlayerFacingAngleToPlayer(playerid, closestID);
Rezzing[playerid] = true;
BeingRezzed[closestID] = true;
}
else if(Rezzing[playerid] && GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
{
ClearAnimations(playerid);
Rezzing[playerid] = false;
if(PlayersRezzingPlayer[closestID] == 0) BeingRezzed[closestID] = false;
}
}
else return 1;
}
if(newkeys & KEY_SECONDARY_ATTACK)
{
if(IsPlayerDead[playerid])
{
cmd_respawn(playerid, "");
}
}
return BO_OnPlayerKeyStateChange(playerid, newkeys, oldkeys);
}
#if defined _ALS_OnPlayerKeyStateChange
#undef OnPlayerKeyStateChange
#else
#define _ALS_OnPlayerKeyStateChange
#endif
#define OnPlayerKeyStateChange BO_OnPlayerKeyStateChange
Quellcode zum Hauptscript
{
//Anderer Code...
if(pInfo[playerid][JustLoggedIn] == false && pInfo[playerid][JustRegistered] == false)
{
if(!IsPlayerDead[playerid])
{
UseTeleports[playerid] = true;
SetSpawnProtection(playerid);
ClearAnimations(playerid);
}
else
{
SetPlayerPos(playerid, pDeathLoc[playerid][0], pDeathLoc[playerid][1], pDeathLoc[playerid][2]);
SetPlayerFacingAngle(playerid, pDeathLoc[playerid][3]);
SetCameraBehindPlayer(playerid);
TogglePlayerControllable(playerid, 0);
ApplyAnimation(playerid, "PED", "KO_shot_front", 4.1, 0, 1, 1, 1, 1);
}
return 1;
}
return 1;
}
{
if(GetPlayerVirtualWorld(playerid) == 0)
{
SetPlayerHealth(playerid, FLOAT_INFINITY);
ClearAnimations(playerid);
GetPlayerPos(playerid, pDeathLoc[playerid][0], pDeathLoc[playerid][1], pDeathLoc[playerid][2]);
GetPlayerFacingAngle(playerid, pDeathLoc[playerid][3]);
}
IsPlayerDead[playerid] = true;
GetPlayerName(killerid, kID, sizeof(kID));
format(LastKilledPlayer[playerid], MAX_PLAYER_NAME, "%s", kID);
if(killerid != INVALID_PLAYER_ID) //Killed by another player
{
if(!strcmp(kID, LastKilledPlayer[playerid], true, MAX_PLAYER_NAME))
{
TimesLastKilledPlayer[playerid]++;
switch(TimesLastKilledPlayer[playerid])
{
case 1:
{
GivePlayerMoneyEx(killerid, money/100*5);
GivePlayerMoneyEx(playerid, -money/100*15);
SetPlayerScore(killerid, GetPlayerScore(playerid) + 1);
}
case 2:
{
GivePlayerMoneyEx(killerid, money/100*2);
GivePlayerMoneyEx(playerid, -money/100*15);
SetPlayerScore(killerid, GetPlayerScore(playerid) + 1);
}
case 3:
{
GivePlayerMoneyEx(killerid, money/100*1);
GivePlayerMoneyEx(playerid, -money/100*15);
SetPlayerScore(killerid, GetPlayerScore(playerid) + 1);
}
}
}
else
{
GivePlayerMoneyEx(killerid, money/100*10);
GivePlayerMoneyEx(playerid, -money/100*15);
SetPlayerScore(killerid, GetPlayerScore(playerid) + 1);
}
}
if(killerid == INVALID_PLAYER_ID) //Suicide
{
GivePlayerMoneyEx(playerid, -money/100*15);
}
pInfo[playerid][Deaths] += 1;
return 1;
}