Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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];
- new line[100];
- new create[MAX_PLAYERS];
- new c[MAX_PLAYERS];
- 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;
- 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;
- }
- stock DeleteObject(playerid)
- {
- new
- File:file,
- writer[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(writer, 100, "//--------------(Remove this and the previous line to apply the delete)--------------\r\n");
- fwrite(file, writer);
- fclose(file);
- return 1;
- }
- stock EditingObject(playerid)
- {
- new
- File:file,
- editor[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(editor, 100, "//--------------(Remove this and the previous line to apply the edit)--------------\r\n");
- fwrite(file, editor);
- 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");
- c[playerid] = 1;
- return 1;
- }
- CMD:deleteobject(playerid, params[])
- {
- DestroyObject(cobj);
- if(c[playerid] == 0) return 0;
- DeleteObject(playerid);
- c[playerid] = 0;
- return 1;
- }
- CMD:editobject(playerid, params[])
- {
- EditObject(playerid, cobj);
- EditingObject(playerid);
- }
- 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);
- model[cobj] = object;
- create[playerid] = 1;
- }
- }
- 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);
- }
- if(response == EDIT_RESPONSE_CANCEL)
- {
- DestroyObject(cobj);
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement