10.08.2012, 21:46
Hello all, i am writing here because today I've got a problem with my objects in game.
I had already created a command to spawn objects and it works perferct, but the problem is writing them in a file:
My spawning command:
And there is my save objects to file command:
Now i am getting that in my objects.txt
So i am out of ideas of how to get all spawned objects model id's and put them in the file
I would be very pleased and thankful if any of you could help me
Sorry for my bad english.
I had already created a command to spawn objects and it works perferct, but the problem is writing them in a file:
My spawning command:
Код:
dcmd_object(playerid,params[]) { if(Player[playerid][admin] < 4) { return SendClientMessage (playerid,COLOR_RED,"Command unavailable"); } new object; if(sscanf(params,"d",object)) { return SendClientMessage (playerid,GELTONA,"Usage: /object [object model id]"); } new Float:bx, Float:by, Float:bz, Float:ba; GetPlayerPos(playerid, bx, by, bz); GetPlayerFacingAngle(playerid, ba); bx += (floatsin(-ba, degrees)); by += (floatcos(-ba, degrees)); CreateObject(object, bx, by, bz-0.5, 0, 0, ba); ApplyAnimation(playerid, "BOMBER","BOM_Plant_In",4.0,0,0,0,0,0); return 1; }
Код:
dcmd_saveobjects(playerid,params[]) { if(Player[playerid][admin] < 4) { return SendClientMessage(playerid,COLOR_RED,"Command unavailable"); } new File:obj = fopen("objects.txt", io_append); for(new i = 0; i < MAX_OBJECTS; i++) //checking all objects { for(new a=0; a < IsValidObject(i); a++) //choosing those, whose spawned { new Float:objx, Float:objy, Float:objz, Float:objrotx, Float:objroty, Float:objrotz,string[256]; GetObjectPos(i,objx,objy,objz); GetObjectRot(i,objrotx,objroty,objrotz); format(string,sizeof(string), "CreateObject(%d,%f,%f,%f,%f,%f,%f)\r\n",Missing Object model id,objx,objy,objz,objrotx,objroty,objrotz); fwrite(obj, string); } } new string2[256]; format(string2,sizeof(string2), "/////////////////////////////////////////END/////////////////////////////////// \r\n"); fwrite(obj, string2); fclose(obj); return 1; }
Код:
CreateObject(-306.100402,1529.891235,74.859375,0.000000,0.000000,201.506210) //as you can see there is no object model id after the "(" CreateObject(-304.312042,1531.305175,74.859375,0.000000,0.000000,95.911888) CreateObject(-302.114410,1519.946289,74.859375,0.000000,0.000000,184.658599) /////////////////////////////////////////END///////////////////////////////////
I would be very pleased and thankful if any of you could help me
Sorry for my bad english.