Data loading (Dini)
#1

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

https://sampforum.blast.hk/showthread.php?tid=101560
this tutorial of dini "READ" now
Reply
#3

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

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);
Reply
#5

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

Give me all the parts you scripted maybe I can notice a wrong on it thx
Reply
#7

But meanwhile... Any other ideas?
Reply
#8

No one knows how to load weapons and position from a file when the player logs in?
Reply
#9

Damn. If no one knows, then i have to find a premade system and look how they did...
Reply
#10

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

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

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)