03.05.2015, 22:45
terminй, tiens:
PHP Code:
#include <zcmd>
#include <dini>
#include <sscanf2>
#define MAX_OBJECTS 500
new totalobjets = 0;
enum ObInfo
{
Model,
Float:Pos[3];
}
new ObjetInfo[MAX_OBJECTS][ObInfo];
public OnGameModeInit()
{
LoadObjects();
return 1;
}
stock LoadObjects()
{
new string[128];
for(new i = 1; i < MAX_OBJECTS; i++)
{
format(string,sizeof(string),"objets/%d.ini",i);
if(dini_Exists(string))
{
ObjetInfo[i][Pos][0] = dini_Float(string, "X");
ObjetInfo[i][Pos][1] = dini_Float(string, "Y");
ObjetInfo[i][Pos][2] = dini_Float(string, "Z");
ObjetInfo[i][Model] = dini_Int(string, "Model");
CreateObject(ObjetInfo[i][Model], ObjetInfo[i][Pos][0], ObjetInfo[i][Pos][1], ObjetInfo[i][Pos][2], 0, 0, 0, 100);
totalobjets += 1;
}
}
return 1;
}
stock SaveObject(objet)
{
new string[128];
format(string,sizeof(string),"objets/%d.ini",objet);
if(dini_Exists(string))
{
dini_IntSet(string, "Model", ObjetInfo[objet][Model]);
dini_FloatSet(string, "X", ObjetInfo[objet][Pos][0]);
dini_FloatSet(string, "Y", ObjetInfo[objet][Pos][1]);
dini_FloatSet(string, "Z", ObjetInfo[objet][Pos][2]);
}
else {
dini_Create(string);
dini_IntSet(string, "Model", ObjetInfo[objet][Model]);
dini_FloatSet(string, "X", ObjetInfo[objet][Pos][0]);
dini_FloatSet(string, "X", ObjetInfo[objet][Pos][1]);
dini_FloatSet(string, "X", ObjetInfo[objet][Pos][2]);
}
return 1;
}
CMD:objet(playerid, params[])
{
new id, cdt[5], Float:PosJ[3];
if(sscanf(params, "is[5]", id, cdt)) return SendClientMessage(playerid, -1, "Commande: /objet ID [SAVE(OUI/NON)]");
if(strcmp(cdt, "OUI", true) == 0)
{
totalobjets += 1;
new objet = totalobjets;
GetPlayerPos(playerid, PosJ[0], PosJ[1], PosJ[2]);
for(new i = 0; i < 3; i++) ObjetInfo[objet][Pos][i] = PosJ[i];
ObjetInfo[objet][Model] = id;
CreateObject(id, PosJ[0], PosJ[1], PosJ[2], 0, 0, 0, 100);
SetPlayerPos(playerid, PosJ[0]+2, PosJ[1]+2, PosJ[2]);
SaveObject(objet);
}
else if(strcmp(cdt, "NON", true) == 0)
{
GetPlayerPos(playerid, PosJ[0], PosJ[1], PosJ[2]);
CreateObject(modelid, PosJ[0], PosJ[1], PosJ[2], 0, 0, 0, 100);
SetPlayerPos(playerid, PosJ[0]+2, PosJ[1]+2, PosJ[2]);
}
else return SendClientMessage(playerid, -1, "SAVE doit кtre OUI OU NON !!!!!!! PFFFF");
return 1;
}