==> OnPlayerDeath Help!<==
#1

So I just simply tried to make a script so that when a player dies, he respawns at Fort Carson hospital and loses some money but when I tried it, the player spawns at the hospital but stays there for like 2 seconds and respawns at the place where you spawn when you connect. So could someone help me out, this is how my script looks like:

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    SetPlayerPos(playerid , -320.0716 , 1049.2888 , 20.3403);
    GivePlayerMoney(playerid , -500);
    SendClientMessage(playerid , 0x489048FF , "You have been transported to Fort Carson hospital E.R");
    return 1;
}
Reply
#2

Set the position in OnPlayerSpawn instead.
Reply
#3

Make a variable like : death[playerid] =1; and remove the set player pos on player death.. and place on player spawn if the player is died eg:

pawn Код:
// on player spawn
    if (death [playerid] == 1)
    {
         // set player pos at fc hospital
    }
    else // he is not died
    {
        // normal spawn
    }
Reply
#4

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Set the position in OnPlayerSpawn instead.
with this player will directly spawn in hospital without dying.


Well, i think there should be some variables and timer to do that.
Код:
new InHospital[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    InHospital[playerid] = 0;
    return 1;
}

public OnPlayerDeath(playerid)
{
    InHospital[playerid] = 1;
    if(InHospital[playerid] == 1)
    {
        SetPlayerPos(playerid , -320.0716 , 1049.2888 , 20.3403);
        SetTimer("spawn",your time interval, 0);
    }
    return 1;
}


forward spawn(playerid);
public spawn(playerid)
{
   InHospital[playerid] = 0;
   SpawnPlayer(playerid);
   return 1;
}
Reply
#5

Alright thanks for help but I'm getting this error:
pawn Код:
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(24) : error 017: undefined symbol "playerid"
And here's my code: (not sure if I made that variable correctly since i'm pretty new to those)
pawn Код:
main()

{
    print("\n----------------------------------");
    print(" RPtest ");
    print("----------------------------------\n");
}




#endif

new death[playerid] =1;
pawn Код:
public OnPlayerSpawn(playerid)
{
    if (death [playerid] == 1)
    {
    SetPlayerPos(playerid , -320.0716 , 1049.2888 , 20.3403);
    }
    else
    {
    SetPlayerPos(playerid , 261.4925 , -270.4117 , 1.5781);
    }
    SendClientMessage(playerid , 0x489048FF , "You can type /commands to see the commands that are currently available.");
    CreateVehicle( 581 , 266.2822, -275.4132 , 1.5781 , 82.2873 , 0 , 1 , 60);
     return 1;
}
Reply
#6

try my codes
Reply
#7

@Iron3man, I'm getting some errors:

pawn Код:
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(93) : warning 217: loose indentation
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(103) : warning 217: loose indentation
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(105) : warning 217: loose indentation
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(105) : error 029: invalid expression, assumed zero
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(105) : error 017: undefined symbol "spawn"
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(106) : error 029: invalid expression, assumed zero
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(106) : error 017: undefined symbol "spawn"
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(113) : warning 225: unreachable code
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(113) : error 029: invalid expression, assumed zero
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(113) : error 004: function "OnVehicleSpawn" is not implemented
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(118) : warning 225: unreachable code
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(118) : error 029: invalid expression, assumed zero
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(118) : error 004: function "OnVehicleDeath" is not implemented
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(123) : warning 225: unreachable code
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(123) : error 029: invalid expression, assumed zero
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(123) : error 004: function "OnPlayerText" is not implemented
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(128) : warning 225: unreachable code
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(128) : error 029: invalid expression, assumed zero
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(128) : error 004: function "OnPlayerCommandText" is not implemented
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(130) : error 017: undefined symbol "cmdtext"
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(135) : warning 217: loose indentation
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(135) : error 017: undefined symbol "cmdtext"
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(152) : error 017: undefined symbol "cmdtext"
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(162) : error 017: undefined symbol "cmdtext"
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(169) : error 017: undefined symbol "cmdtext"
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(177) : error 017: undefined symbol "cmdtext"
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(185) : error 017: undefined symbol "cmdtext"
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(193) : error 017: undefined symbol "cmdtext"
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(205) : warning 217: loose indentation
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(205) : error 017: undefined symbol "cmdtext"
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(218) : error 017: undefined symbol "cmdtext"
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(230) : error 017: undefined symbol "cmdtext"
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(236) : warning 217: loose indentation
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(236) : error 017: undefined symbol "cmdtext"
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(242) : warning 217: loose indentation
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(245) : warning 225: unreachable code
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(245) : error 029: invalid expression, assumed zero
C:\Users\Sami\Desktop\samp03x_svr_R2_win32\gamemodes\RPtest.pwn(245) : error 004: function "OnPlayerEnterVehicle" is not implemented

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


26 Errors.
And here's my code, not sure if I did something wrong though:

pawn Код:
main()

{
    print("\n----------------------------------");
    print(" RPtest ");
    print("----------------------------------\n");
}




#endif
new InHospital[MAX_PLAYERS];
new Job[256];
new Job2[256];
new Job3[256];
new Job4[256];

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    InHospital[playerid] = 1;
    if(InHospital[playerid] == 1)
    {
        SetPlayerPos(playerid , -320.0716 , 1049.2888 , 20.3403);
        SetTimer( "spawn" , 5000 , 0);
    return 1;
}
forward spawn(playerid);
public spawn(playerid)
{
   InHospital[playerid] = 0;
   SpawnPlayer(playerid);
   return 1;
}
Reply
#8

you have not putted } above the return 1;
in onplayerdeath


pls +rep if i help you
Reply
#9

Unclosed bracket:

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    InHospital[playerid] = 1;
    if(InHospital[playerid] == 1)
    {
        SetPlayerPos(playerid , -320.0716 , 1049.2888 , 20.3403);
        SetTimer( "spawn" , 5000 , 0);
    }//Here
    return 1;
     
}
forward spawn(playerid);
public spawn(playerid)
{
   InHospital[playerid] = 0;
   SpawnPlayer(playerid);
   return 1;
}
EDIT: shit too late ;x
Reply
#10

Well thanks for help but it's still the same thing, I spawn to FC hospital and stay there for a while, then I die again and spawn at the noobspawn :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)