SA-MP Forums Archive
[Pedido] Como fazer para salvar obejetos no player !!!! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Pedido] Como fazer para salvar obejetos no player !!!! (/showthread.php?tid=515328)



Como fazer para salvar obejetos no player !!!! - Marlon307 - 25.05.2014

eu tenho uma [fp] que seta um obejeto no player, e queria uma ajuda para fazer essa [fs] salva-se um objeto no player para qundo ele logasse novamente o objeto ira dar spawn nele


Re: Como fazer para salvar obejetos no player !!!! - MatheusDalZot - 25.05.2014

Basta vocк criar um arquivo ex:
pawn Код:
//no topo as variбveis respectivas ao objeto do slot 1
new ObjSlot1[MAX_PLAYERS];
new IDObjeto1[MAX_PLAYERS];
new BoneObj1[MAX_PLAYERS];
new Float:PosX1[MAX_PLAYERS];
new Float:PosY1[MAX_PLAYERS];
new Float:PosZ1[MAX_PLAYERS];
new Float:RotX1[MAX_PLAYERS];
new Float:RotY1[MAX_PLAYERS];
new Float:RotZ1[MAX_PLAYERS];
new Float:TamX1[MAX_PLAYERS];
new Float:TamY1[MAX_PLAYERS];
new Float:TamZ1[MAX_PLAYERS];

//onplayerdisconnect
SalvarObjetosPlayer(playerid);

forward SalvarObjetosPlayer(playerid);
public SalvarObjetosPlayer(playerid)
{
new arquivo[128], nomeplayer[24];
GetPlayerName(playerid, nomeplayer, 24);
format(arquivo, 128, "ObjetosPlayer/%s.txt", nomeplayer); // deve criar um pasta chamada ObjetosPlayer dentro da pasta Scriptfiles
if(!dini_Exists(arquivo)) dini_Create(arquivo)
dini_IntSet(arquivo, "ObjSlot1", ObjSlot1[playerid]);
dini_IntSet(arquivo, "IDObjeto1", IDObjeto1[playerid]);
dini_IntSet(arquivo, "Bone", BoneObj1[playerid]);
dini_FloatSet(arquivo, "PosX1", PosX1[playerid]);
dini_FloatSet(arquivo, "PosY1", PosY1[playerid]);
dini_FloatSet(arquivo, "PosZ1", PosZ1[playerid]);

//aqui vocк continua com as respectivas variaveis

return 1;
}

//em onplayerspawn vocк poe isso
CarregarObjetosPlayer(playerid);

//no fim do gm
forward CarregarObjetosPlayer(playerid);
public CarregarObjetosPlayer(playerid)
{
SetPlayerAttachedObject(playerid,ObjSlot1[playerid],IDObjeto1[playerid],BoneObj1[playerid], PosX1[playerid], PosY1[playerid], PosZ1[playerid], RotX1[playerid], RotY1[playerid], RotZ1[playerid], TamX1[playerid], TamY1[playerid], TamZ1[playerid]);

return 1;
}
//um exemplo de como usar em comando
if(strcmp(cmd, "/arma", true) == 0)
{
ObjSlot1[playerid] = 4;
IDObjeto1[playerid] = 356;
BoneObj1[playerid] 1;
PosX1[playerid] = -0.100000;
PosY1[playerid] = 0.000000;
PosZ1[playerid] = -0.100000;
RotX1[playerid] = 84.399932;
RotY1[playerid] = 112.000000;
RotZ1[playerid] = 10.000000;
TamX1[playerid] = 1.099999;
TamY1[playerid] = 1.000000;
TamZ1[playerid] = 1.000000;
return 1;
}
espero ter ajudado em algo, use isso apenas como base