07.07.2015, 09:05
I was making an open source project in which i was creating a map editor but i need help for edit and delete function.
Here is the filterscript:
And when someone creates any object so it saves the object code to Objects.txt in scriptfiles but i dont know how to replace the previous object code for edit function and how to delete the previous object code for delete function.Help please
Here is the filterscript:
Код:
#include <a_samp> #include <zcmd> #define FILTERSCRIPT #define COL_WHITE "{FFFFFF}" #define COL_GREEN "{00FF00}" #define ANIM_SAVE_FILE "Objects.txt" new object; new cobj; new pnam[MAX_PLAYER_NAME]; public OnFilterScriptInit() { print("Map Editor Loaded"); return 1; } public OnFilterScriptExit() { return 1; } new model[MAX_OBJECTS]; stock SaveObjectToFile(playerid, modelid, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ) { new File:file, line[100]; GetPlayerName(playerid, pnam, sizeof(pnam)); if(!fexist(ANIM_SAVE_FILE))file = fopen(ANIM_SAVE_FILE, io_write); else file = fopen(ANIM_SAVE_FILE, io_append); format(line, 100, "CreateObject(%d, %f, %f, %f, %f, %f, %f);\r\n", modelid, fX, fY, fZ, fRotX, fRotY, fRotZ); fwrite(file, line); fclose(file); return 1; } CMD:createobject(playerid, params[]) { ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, ""COL_GREEN"Objects", ""COL_WHITE"Enter the object id you want to add", "OK", "Cancel"); return 1; } CMD:editobject(playerid, params[]) { EditObject(playerid, cobj); } CMD:deleteobject(playerid, params[]) { DestroyObject(cobj); } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == 1) { if(response) { new Float:x, Float:y, Float:z; object = strval(inputtext); GetPlayerPos(playerid, x, y, z); cobj = CreateObject(object, x-5, y, z, 0.0, 0.0, 0.0); EditObject(playerid, cobj); GameTextForPlayer(playerid, "~g~Hold ~w~~k~~PED_SPRINT~ ~g~to move the camera",5000,3); model[cobj] = object; } } return 1; } public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ) { if(response == EDIT_RESPONSE_FINAL) { SaveObjectToFile(playerid, model[objectid], fX, fY, fZ, fRotX, fRotY, fRotZ); } return 1; }