Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- DINAMICNO KREIRANJE LABELA
- BY ZIXON
- v1.0.0
- */
- #include <a_samp>
- #include <zcmd>
- #include <streamer>
- #include <YSI\y_ini>
- /////////// cuvanje i ostalo
- #define LABEL_FILE "Labels/%d.ini"
- #define MAX_L 200
- enum lCuvanje
- {
- Float:PozicijaX,
- Float:PozicijaY,
- Float:PozicijaZ,
- Text[256],
- Namesten
- };
- new LabelC[MAX_L][lCuvanje];
- new Text3D:Label[sizeof(LabelC)];
- ///////////// ucitavanje
- forward Load_Label(lid, name[], value[]);
- public Load_Label(lid, name[], value[])
- {
- INI_Float("PozicijaX",LabelC[lid][PozicijaX]);
- INI_Float("PozicijaY",LabelC[lid][PozicijaY]);
- INI_Float("PozicijaZ",LabelC[lid][PozicijaZ]);
- INI_String("Text",LabelC[lid][Text],256);
- INI_Int("Namesten",LabelC[lid][Namesten]);
- return 1;
- }
- ///////////// sejvanje labela
- stock L_Save(lid)
- {
- new LabellFile[128];
- format(LabellFile, sizeof(LabellFile), LABEL_FILE, lid);
- new INI:File = INI_Open(LabellFile);
- INI_WriteFloat(File, "PozicijaX", LabelC[lid][PozicijaX]);
- INI_WriteFloat(File, "PozicijaY", LabelC[lid][PozicijaY]);
- INI_WriteFloat(File, "PozicijaZ", LabelC[lid][PozicijaZ]);
- INI_WriteString(File, "Text", LabelC[lid][Text]);
- INI_WriteInt(File, "Namesten", LabelC[lid][Namesten]);
- INI_Close(File);
- return 1;
- }
- ///////////// komande
- CMD:labelcreate(playerid, params[])
- {
- ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Kreiranje labela", "Unesi tekst:", "Unesi", "Odustani");
- return 1;
- }
- CMD:labeldelete(playerid, params[])
- {
- for(new cc; cc < MAX_L; cc++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 1.5, LabelC[cc][PozicijaX], LabelC[cc][PozicijaY], LabelC[cc][PozicijaZ]))
- {
- if(LabelC[cc][Namesten] == 1)
- {
- DestroyDynamic3DTextLabel(Label[cc]);
- LabelC[cc][PozicijaX] = 0;
- LabelC[cc][PozicijaY] = 0;
- LabelC[cc][PozicijaZ] = 0;
- LabelC[cc][Namesten] = 0;
- strmid(LabelC[cc][Text], "0", 0, strlen("0"), 255);
- L_Save(cc);
- new l_file_delete[100];
- format(l_file_delete,128,"Labels/%d.ini", cc);
- fremove(l_file_delete);
- new string[60];
- format(string,sizeof(string), "Obrisao si label id %d.", cc);
- SendClientMessage(playerid, -1, string);
- }
- }
- }
- return 1;
- }
- //////////// callbacks
- public OnGameModeInit()
- {
- for(new cc = 0; cc < sizeof(LabelC); cc++)
- {
- new LabelFile[60];
- format(LabelFile, sizeof(LabelFile), LABEL_FILE, cc);
- if(fexist(LabelFile))
- {
- INI_ParseFile(LabelFile, "Load_Label", .bExtra = true, .extra = cc);
- if(LabelC[cc][Namesten] == 1)
- {
- new string[256];
- format(string,sizeof(string),LabelC[cc][Text]);
- Label[cc] = CreateDynamic3DTextLabel(string, -1, LabelC[cc][PozicijaX], LabelC[cc][PozicijaY], LabelC[cc][PozicijaZ], 5);
- }
- }
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == 1)
- {
- if(!response) return 1;
- if(response)
- {
- if(strlen(inputtext) == 0) return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Kreiranje labela", "Unesi tekst:", "Unesi", "Odustani");
- else if(strlen(inputtext) > 0)
- {
- new lvariable = 0;
- new Float:Pos[3], string[256];
- GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
- for(new cc = 0; cc < sizeof(LabelC); cc++)
- {
- if(LabelC[cc][Namesten] == 1)
- {
- lvariable = cc + 1;
- }
- }
- if(lvariable > MAX_L) return SendClientMessage(playerid, -1, "Nije moguce kreiranje vise od 200 labela!");
- LabelC[lvariable][PozicijaX] = Pos[0];
- LabelC[lvariable][PozicijaY] = Pos[1];
- LabelC[lvariable][PozicijaZ] = Pos[2];
- LabelC[lvariable][Namesten] = 1;
- format(string, sizeof(string), "%s", inputtext);
- strmid(LabelC[lvariable][Text], string, 0, strlen(string), 255);
- Label[lvariable] = CreateDynamic3DTextLabel(string, -1, LabelC[lvariable][PozicijaX], LabelC[lvariable][PozicijaY], LabelC[lvariable][PozicijaZ], 20);
- L_Save(lvariable);
- format(string, sizeof(string), "Napravio si label sa textom %s, id labela - %d.", inputtext, lvariable);
- SendClientMessage(playerid, -1, string);
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement