hiding spawn button
#1

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
Reply
#2

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.
Reply
#3

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
Reply
#4

Код:
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.
Reply
#5

Quote:
Originally Posted by godless_phoenix
Посмотреть сообщение
delete.
ahm?
Reply
#6

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?
Reply
#7

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.
Reply
#8

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?
Reply
#9

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.
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)