hiding spawn button -
MrCesar - 16.10.2016
Hello guys, how can I save the player position before he disconnects, and how do I make him spawn right after he enters his password? thanks in advance
Re: hiding spawn button -
DTV - 16.10.2016
To save a player's position before they disconnect, simply retrieve their x,y,z coords via GetPlayerPos and save it to the player's account under OnPlayerDisconnect. As for having them spawn in right after logging into their account, use SpawnPlayer(playerid) after they've successfully logged in.
Re: hiding spawn button -
MrCesar - 16.10.2016
Quote:
Originally Posted by DTV
To save a player's position before they disconnect, simply retrieve their x,y,z coords via GetPlayerPos and save it to the player's account under OnPlayerDisconnect. As for having them spawn in right after logging into their account, use SpawnPlayer(playerid) after they've successfully logged in.
|
I did this, but it just leaves the player on the login screen with <<< >>> Spawn buttons, you need to press spawn to login. SpawnPlayer didn't work tho..any ideas? And how do I save the pos to his account? ty
Re: hiding spawn button -
godless_phoenix - 16.10.2016
Код:
public OnPlayerConnect(playerid)
{
TogglePlayerSpectating(playerid, true);
//Get pos data to an array and set it in onplayerspawn.
TogglePlayerSpectating(playerid, false);
SpawnPlayer(playerid);
}
public OnPlayerRequestClass(playerid,classid)
{
TogglePlayerSpectating(playerid, 1);
SetTimerEx("SkipOnPlayerRequestClass", 100, false, "i", playerid);
return 1;
}
forward SkipOnPlayerRequestClass(playerid);
public SkipOnPlayerRequestClass(playerid)
{
TogglePlayerSpectating(playerid, 0);
return 1;
}
public OnPlayerSpawn(playerid)
{
SetPlayerSkin(playerid,50);
SetPlayerPos(playerid, 0,0,0);
SetPlayerFacingAngle(playerid, 0);
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
return 1;
}
That hides spawn buttons on deaths too. (even with F4)
But probably, SetSpawnInfo should be used before SpawnPlayer for a better solution. IDK.
Re: hiding spawn button -
MrCesar - 16.10.2016
Quote:
Originally Posted by godless_phoenix
delete.
|
ahm?
Re: hiding spawn button -
MrCesar - 16.10.2016
Quote:
Originally Posted by godless_phoenix
Код:
public OnPlayerConnect(playerid)
{
TogglePlayerSpectating(playerid, true);
//Get pos data to an array and set it in onplayerspawn.
TogglePlayerSpectating(playerid, false);
SpawnPlayer(playerid);
}
public OnPlayerRequestClass(playerid,classid)
{
TogglePlayerSpectating(playerid, 1);
SetTimerEx("SkipOnPlayerRequestClass", 100, false, "i", playerid);
return 1;
}
forward SkipOnPlayerRequestClass(playerid);
public SkipOnPlayerRequestClass(playerid)
{
TogglePlayerSpectating(playerid, 0);
return 1;
}
public OnPlayerSpawn(playerid)
{
SetPlayerSkin(playerid,50);
SetPlayerPos(playerid, 0,0,0);
SetPlayerFacingAngle(playerid, 0);
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
return 1;
}
That hides spawn buttons on deaths too. (even with F4)
But probably, SetSpawnInfo should be used before SpawnPlayer for a better solution. IDK.
|
Thanks! but how do I get the data tho, that's what I was asking lol

the save data I mean, like GetPlayerPos?
Re: hiding spawn button -
godless_phoenix - 16.10.2016
Im using mysql for storing data. There are couple of ways to do that like file systems. Im checking login name and password on onplayerconnect via mysql_query. I have x,y,z datas for each player in players table. So if login successful, i set that datas to my players array like; cache_get_value_index_float(i, columnno, myplayers[playerid][x]); after that my previous answer comes and solves everything. Lastly, im using setplayerpos like SetPlayerPos(playerid, myplayers[playerid][x],myplayers[playerid][y],myplayers[playerid][z]); Ofcouse you will need to update players mysql row for his last x,y,z positions on onplayerdisconnect too. Thats it.
Re: hiding spawn button -
MrCesar - 16.10.2016
Quote:
Originally Posted by godless_phoenix
Im using mysql for storing data. There are couple of ways to do that like file systems. Im checking login name and password on onplayerconnect via mysql_query. I have x,y,z datas for each player in players table. So if login successful, i set that datas to my players array like; cache_get_value_index_float(i, columnno, myplayers[playerid][x]); after that my previous answer comes and solves everything. Lastly, im using setplayerpos like SetPlayerPos(playerid, myplayers[playerid][x],myplayers[playerid][y],myplayers[playerid][z]); Ofcouse you will need to update players mysql row for his last x,y,z positions on onplayerdisconnect too. Thats it.
|
I use Y_INI for that, how to store the positions in a variable?
Re: hiding spawn button -
SickAttack - 17.10.2016
Consult a tutorial on how to save and load data.
Use TogglePlayerSpectating to hide the class selection buttons. Use SetSpawnInfo then SpawnPlayer to remove the need of the class selection.
Re: hiding spawn button -
MrCesar - 17.10.2016
Quote:
Originally Posted by SickAttack
Consult a tutorial on how to save and load data.
Use TogglePlayerSpectating to hide the class selection buttons. Use SetSpawnInfo then SpawnPlayer to remove the need of the class selection.
|
Thanks got it to spawn right after you click the button, I didn't find any tutorials regarding saving my position..
I need to write it down to an INI file and open it like it was said? I am really confused lol sorry