Stay within the world boundaries when died -
xX4m4zingXx - 23.01.2015
When I die in my game, I get this error and the whole screen turns strange.
I have these things that do something with spawning:
Код:
public OnGameModeInit()
{
DisableInteriorEnterExits();
print("Gamemode Started.");
return 1;
}
Код:
public OnPlayerSpawn(playerid)
{
PlayerInfo[playerid][pSkin] = GetPlayerSkin(playerid); //i dont know your variables
SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
SetSpawnInfo(playerid, 0, 79, 1549.6141, -1675.5640, 15.0438, 91.6558, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
return 1;
}
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""COLOR_WHITE"Registering...",""COLOR_RED"You have entered an invalid password.\n"COLOR_WHITE"Type your password below to register a new account.","Register","Quit");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Rights",0);
INI_WriteInt(File,"Skin",79);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_Close(File);
SetSpawnInfo(playerid, 0, 79, 1549.6141, -1675.5640, 15.0438, 91.6558, 0, 0, 0, 0, 0, 0);
SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
SpawnPlayer(playerid);
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
SetSpawnInfo(playerid, 0, 79, 1549.6141, -1675.5640, 15.0438, 91.6558, 0, 0, 0, 0, 0, 0);
SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
SpawnPlayer(playerid);
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COLOR_WHITE"Login",""COLOR_RED"You have entered an incorrect password.\n"COLOR_WHITE"Type your password below to login.","Login","Quit");
}
return 1;
}
}
}
return 1;
}
Код:
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Rights",PlayerInfo[playerid][pRights]);
INI_WriteInt(File,"Skin",GetPlayerSkin(playerid));
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_Close(File);
SetSpawnInfo(playerid, 0, 79, 1549.6141, -1675.5640, 15.0438, 91.6558, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
return 1;
}
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;
return 1;
}
What can I remove and what can I improve?
Re: Stay within the world boundaries when died -
Abagail - 23.01.2015
Try placing:
pawn Код:
SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
SetSpawnInfo(playerid, 0, 79, 1549.6141, -1675.5640, 15.0438, 91.6558, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
in the OnPlayerDeath callback.
Re: Stay within the world boundaries when died -
xX4m4zingXx - 23.01.2015
I have so much places where there is something with coordinates, can I remove some of these and what effect would it have?
Re: Stay within the world boundaries when died -
xX4m4zingXx - 23.01.2015
Nope, I don't have one.
Re: Stay within the world boundaries when died -
xX4m4zingXx - 23.01.2015
Quote:
Originally Posted by ******
Well then add one.
|
Where would I add it and I want the skin to take it from the player file which is.
PlayerInfo[playerid][pSkin]
Re: Stay within the world boundaries when died -
PowerPC603 - 23.01.2015
Having this under OnPlayerDisconnect also doesn't make any sense:
pawn Код:
SetSpawnInfo(playerid, 0, 79, 1549.6141, -1675.5640, 15.0438, 91.6558, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
The player is leaving the game, there is no reason to set spawninfo and spawn him.
Re: Stay within the world boundaries when died -
Sime30 - 23.01.2015
And put SetSpawnInfo under OnPlayerRequestClass, you don't need more of them
Re: Stay within the world boundaries when died -
xX4m4zingXx - 27.01.2015
Okay, I added one.
But my problem now is that when I die, it sets my position to 0, 0, 0.
Re: Stay within the world boundaries when died -
xX4m4zingXx - 28.01.2015
Bump