Data loading (Dini) -
sim_sima - 03.05.2011
Hello guys.
I have made a login/register system for my server.
I have an issue with weapon and position loading.
It works fine, almost... When the player disconnects, his weapons and position gets saved.
I dont know whats the best way to load it. It doesnt work if i try to load it in "OnDialogResponse" for the login dialog, and it doesnt work int the "OnPlayerRequestSpawn" callback. Only place where it works is in the "OnPlayerSpawn" callback. But the problem here is, when the player dies, he spawns at the saved position from where he disconnected, and gets the weapons from last time he disconnected.
Hope someone can help me. Thank you.
Re: Data loading (Dini) -
TheGarfield - 03.05.2011
https://sampforum.blast.hk/showthread.php?tid=101560
this tutorial of dini "READ" now
Re: Data loading (Dini) -
sim_sima - 03.05.2011
Quote:
Originally Posted by TheGarfield
|
Thanks. But i know how to use Dini, and the only things im having problems with is weapon and position loading.
Re: Data loading (Dini) -
The_Tough - 03.05.2011
OnDialogResponse ? Why you use this ?
Save his pos OnPlayerDisconnect
new LastPos = GetPlayerPos(playerid,X,Y,Z);
dini_IntSet(file,"LastPos");
and
Try OnPlayerRequest spawn
like , ExitPos = dini_Get(file,"LastPos");
SetPlayerPos(playerid,ExitPos);
Re: Data loading (Dini) -
sim_sima - 03.05.2011
Quote:
Originally Posted by The_Tough
OnDialogResponse ? Why you use this ?
Save his pos OnPlayerDisconnect
new LastPos = GetPlayerPos(playerid,X,Y,Z);
dini_IntSet(file,"LastPos");
and
Try OnPlayerRequest spawn
like , ExitPos = dini_Get(file,"LastPos");
SetPlayerPos(playerid,ExitPos);
|
Yes, i did that already. But my problem is loading it again when the player connects to the server again.
And loading position and weapons in the "OnPlayerRequestSpawn" doesnt work.
Re: Data loading (Dini) -
The_Tough - 03.05.2011
Give me all the parts you scripted maybe I can notice a wrong on it thx
Re: Data loading (Dini) -
sim_sima - 03.05.2011
But meanwhile... Any other ideas?
Re: Data loading (Dini) -
sim_sima - 03.05.2011
No one knows how to load weapons and position from a file when the player logs in?
Re: Data loading (Dini) -
sim_sima - 03.05.2011
Damn. If no one knows, then i have to find a premade system and look how they did...
Re: Data loading (Dini) -
Mikkel_Pedersen - 03.05.2011
pawn Код:
new SpawnedOnce[MAX_PLAYERS];
//OnPlayerConnect(playerid)
SpawnedOnce[playerid] = 0;
//OnPlayerSpawn(playerid)
if(SpawnedOnce[playerid] == 0)
{
//code to load info from their file
//This will only get called if this is the first time they spawn (since they connected)
SpawnedOnce[playerid] = 1;
}
//Other code you use at OnPlayerSpawn
Re: Data loading (Dini) -
DRIFT_HUNTER - 03.05.2011
Quote:
Originally Posted by Mikkel_Pedersen
pawn Код:
new SpawnedOnce[MAX_PLAYERS]; //OnPlayerConnect(playerid) SpawnedOnce[playerid] = 0; //OnPlayerSpawn(playerid) if(SpawnedOnce[playerid] == 0) { //code to load info from their file //This will only get called if this is the first time they spawn (since they connected) SpawnedOnce[playerid] = 1; } //Other code you use at OnPlayerSpawn
|
And that must go under OnPlayerSpawn
I guess he tryed to load player position before he spawned player thats his mistake
Re: Data loading (Dini) -
sim_sima - 03.05.2011
Quote:
Originally Posted by DRIFT_HUNTER
And that must go under OnPlayerSpawn
I guess he tryed to load player position before he spawned player thats his mistake
|
Exacteley. But in the "OnPlayerSpawn" is the only place where it works, but then it will load every time the player dies/respawns
Re: Data loading (Dini) -
sim_sima - 03.05.2011
Quote:
Originally Posted by Mikkel_Pedersen
pawn Код:
new SpawnedOnce[MAX_PLAYERS]; //OnPlayerConnect(playerid) SpawnedOnce[playerid] = 0; //OnPlayerSpawn(playerid) if(SpawnedOnce[playerid] == 0) { //code to load info from their file //This will only get called if this is the first time they spawn (since they connected) SpawnedOnce[playerid] = 1; } //Other code you use at OnPlayerSpawn
|
Thanks. I tried something very similar to this.
*EDIT* Jeg er forresten ogsе dansker