How can I make a player return to there position after they die in this event? -
rangerxxll - 13.09.2011
So, if you /join when a event is started, then you go into a area. And if you die I want it so it returns the player to there last location. I'm not really sure how I would create this, my current code:
pawn Код:
public OnPlayerDeath(playerid)
{
if(PartyStarted == true)
SetPlayerPos(playerid, -2666.7739,637.4879,14);
SendClientMessage(playerid, COLOR_RED, "You have died in the event!");
return 1;
}
I put in a random location, but I want it so it returns them to there last location. Thanks for the help.
Re: How can I make a player return to there position after they die in this event? -
[O.z]Caroline - 13.09.2011
Put is in Top of GameMode.
pawn Код:
new Float: posx[MAX_PLAYERS], Float:posy[MAX_PLAYERS], Float:posz[MAX_PLAYERS], bool: PlayerInEvent[MAX_PLAYERS];
Puts is in /join.
pawn Код:
GetPlayerPos(playerid, posx[playerid],posy[playerid],posz[playerid]);
PlayerInEvent[playerid] = true;
and is in OnPlayerSpawn
pawn Код:
if(PlayerInEvent[playerid] = 1) SetPlayerPos(playerid, posx[playerid],posy[playerid],posz[playerid]);
\/\/
Re: How can I make a player return to there position after they die in this event? -
Basicz - 13.09.2011
pawn Код:
new
Float: oldPos[ MAX_PLAYERS ][ 4 ],
bool: inParty[ MAX_PLAYERS ] = { false, ... }
;
CMD:join( playerid, params[ ] )
{
// Your actions/code in the command
GetPlayerPos( playerid, pos[ playerid ][ 0 ], pos[ playerid ][ 1 ], pos[ playerid ][ 2 ] );
GetPlayerFacingAngle( playerid, pos[ playerid ][ 3 ] );
inParty[ playerid ] = true;
return 1;
}
public OnPlayerDeath( playerid, killerid, reason )
{
if ( inParty[ playerid ] )
{
SendClientMessage( playerid, -1, "You have died in the event, you left it." );
}
return 1;
}
public OnPlayerSpawn( playerid )
{
if ( inParty[ playerid ] )
{
inParty[ playerid ] = false;
SetPlayerPos( playerid, pos[ playerid ][ 0 ], pos[ playerid ][ 1 ], pos[ playerid ][ 2 ] );
SetPlayerFacingAngle( playerid, pos[ playerid ][ 3 ] );
}
return 1;
}
Re: How can I make a player return to there position after they die in this event? -
grand.Theft.Otto - 13.09.2011
You have to create a global variable:
pawn Код:
// top of script
new InEvent[MAX_PLAYERS];
// in the event cmd or however the event is started
InEvent[playerid] = 1; // tells the server that the player joined in/is in the event (1 = true)
// onplayerspawn
if(InEvent[playerid] == 1) // if the player was in the event when he died
{
// set the player position back to the event
// other stuff here
return 1;
}
Re: How can I make a player return to there position after they die in this event? -
rangerxxll - 13.09.2011
Would this work?
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/event", true) == 0)
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFF0000AA,"You can't use this command.");
{
GetPlayerPos(playerid, pData[X], pData[Y], pData[Z]);
GetPlayerFacingAngle(playerid, pData[A]);
SendClientMessageToAll(COLOR_GREEN, "A Event has been started. Use /join to join the event.");
PartyStarted = true;
return 1;
}
}
if(strcmp(cmdtext, "/join", true) == 0)
{
if(PartyStarted == false) return SendClientMessage(playerid, COLOR_RED, "No one has started a event yet.");
if(AtParty[playerid] == true) return SendClientMessage(playerid, COLOR_RED, "You're already in the event, type /leave to leave.");
SetPlayerPos(playerid, 2169.0952,-3170.2466,190);
SetPlayerFacingAngle(playerid, 344.3667);
AtParty[playerid] = true;
SendClientMessage(playerid, COLOR_GREEN, "Welcome to the Event, if you wish to leave use /leave.");
return 1;
}
if(strcmp(cmdtext, "/leave", true) == 0)
{
if(AtParty[playerid] == false) return SendClientMessage(playerid, COLOR_RED, "You're not at the Event.");
SpawnPlayer(playerid);
AtParty[playerid] = false;
return 1;
}
Re: How can I make a player return to there position after they die in this event? -
grand.Theft.Otto - 13.09.2011
Use mine above but replace InEvent with AtParty, and follow the commented (green) text on where to put it.
Re: How can I make a player return to there position after they die in this event? -
[O.z]Caroline - 13.09.2011
Quote:
Originally Posted by rangerxxll
Would this work?
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp(cmdtext, "/event", true) == 0) { if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFF0000AA,"You can't use this command."); { GetPlayerPos(playerid, pData[X], pData[Y], pData[Z]); GetPlayerFacingAngle(playerid, pData[A]); SendClientMessageToAll(COLOR_GREEN, "A Event has been started. Use /join to join the event."); PartyStarted = true; return 1; } }
if(strcmp(cmdtext, "/join", true) == 0) { if(PartyStarted == false) return SendClientMessage(playerid, COLOR_RED, "No one has started a event yet."); if(AtParty[playerid] == true) return SendClientMessage(playerid, COLOR_RED, "You're already in the event, type /leave to leave."); SetPlayerPos(playerid, 2169.0952,-3170.2466,190); SetPlayerFacingAngle(playerid, 344.3667); AtParty[playerid] = true; SendClientMessage(playerid, COLOR_GREEN, "Welcome to the Event, if you wish to leave use /leave."); return 1; }
if(strcmp(cmdtext, "/leave", true) == 0) { if(AtParty[playerid] == false) return SendClientMessage(playerid, COLOR_RED, "You're not at the Event."); SpawnPlayer(playerid); AtParty[playerid] = false; return 1; }
|
yes, this is work!
Re: How can I make a player return to there position after they die in this event? -
Kush - 13.09.2011
Quote:
Originally Posted by grand.Theft.Otto
You have to create a global variable:
pawn Код:
// top of script
new InEvent[MAX_PLAYERS];
// in the event cmd or however the event is started
InEvent[playerid] = 1; // tells the server that the player joined in/is in the event (1 = true)
// onplayerspawn
if(InEvent[playerid] == 1) // if the player was in the event when he died { // set the player position back to the event // other stuff here return 1; }
|
No no no! This is why you use the boolean data type! You can then alternate between the two values (true) and (false).