Saving Objects
#1

How Can I Save Objects OnDisconnect?
Reply
#2

Anyone Who Can Help
Reply
#3

A little more info would help us... Please provide some..
Reply
#4

First of all , stop bumping your topics and read the rules.
second of all , as iPLEOMAX has said. Give us some more information about what you want
Reply
#5

I think he wants that when he spawns a object ingame it will save when the server restarts.
Reply
#6

Quote:
Originally Posted by bartje01
Посмотреть сообщение
I think he wants that when he spawns a object ingame it will save when the server restarts.
Nevermind,

topic creator: You could try learning dini/y_ini , or djhson(Whatever it's name is)
And saving the objects like that. I'm not really experienced myself though

Good luck
Reply
#7

What is the way you create objects? a Map building FS perhaps? Then you have to find some other ways. Try the ones suggested by Funtime.

But if you coded an object creator script yourself then add an extra string with the format of "CreateObject" line Function. Then use the file functions to save it in txt files. Later, include the file to your script.

It's pretty complicated if you are a starter in pawn.
Reply
#8

Im Talking about Player Attached Objects, i made a command that player can hold several objects, and i want to save them when a player disconnects, and when he spawns he's wearing the objects.
Reply
#9

So, what parameters are you using in the attach object command?
like Object ID, Bone ID, Positions, Rotations etc...

Simple Example:

In your attach command:
pawn Код:
SetPVarInt(playerid, "object", objectid); // objectid = the one you entered in the cmd. if you did /hold 1337, then objectid = 1337
In OnPlayerDisconnect:
pawn Код:
new pname[MAX_PLAYER_NAME], objectid, string[30], string2[10];
GetPlayerName(playerid,pname,sizeof(pname);
objectid = GetPVarInt(playerid, "object");
format(string,30,"%s.txt",pname);
format(string2,10,"%i",objectid);
new File:pobject=fopen(string, io_write);
fwrite(pobject, string2);
fclose(pobject);
SetPVarInt(playerid, "object", 0)
In OnPlayerSpawn:
pawn Код:
new pname[MAX_PLAYER_NAME],string[30];
GetPlayerName(playerid,pname,sizeof(pname);
format(string,30,"%s.txt",pname);
if(fexist(string)
{
    new File:pobject=fopen(string, io_read);
    new objectid[10];
    fread(pobject, objectid, sizeof(objectid), false);
    fclose(pobject);
    SetPlayerAttachedObject(strval(objectid),....................
}
There are many other sophisticated/better methods. This is just a basic example.

(Everything is UNTESTED Here!)
Reply
#10

Quote:
Originally Posted by iPLEOMAX
Посмотреть сообщение
So, what parameters are you using in the attach object command?
like Object ID, Bone ID, Positions, Rotations etc...

Simple Example:

In your attach command:
pawn Код:
SetPVarInt(playerid, "object", objectid); // objectid = the one you entered in the cmd. if you did /hold 1337, then objectid = 1337
In OnPlayerDisconnect:
pawn Код:
new pname[MAX_PLAYER_NAME], objectid, string[30], string2[10];
GetPlayerName(playerid,pname,sizeof(pname);
objectid = GetPVarInt(playerid, "object");
format(string,30,"%s.txt",pname);
format(string2,10,"%i",objectid);
new File:pobject=fopen(string, io_write);
fwrite(pobject, string2);
fclose(pobject);
SetPVarInt(playerid, "object", 0)
In OnPlayerSpawn:
pawn Код:
new pname[MAX_PLAYER_NAME],string[30];
GetPlayerName(playerid,pname,sizeof(pname);
format(string,30,"%s.txt",pname);
if(fexist(string)
{
    new File:pobject=fopen(string, io_read);
    new objectid[10];
    fread(pobject, objectid, sizeof(objectid), false);
    fclose(pobject);
    SetPlayerAttachedObject(strval(objectid),....................
}
There are many other sophisticated/better methods. This is just a basic example.

(Everything is UNTESTED Here!)
i have a menu which is /ho only, and will this save all the objects that player is holding?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)