14.02.2015, 03:44
LUMBERJACK JOB
So here\'s a filterscript I have fount, however, I have tweaked it a little. So I don\'t take a majority of credit. Only a little. Rest goes to the owner. I\'d appreciate some rep in return for the work I put into it. However, that is your choice. (I don\'t even know if I can ask for rep, quite new to SA-MP forums :P) - Enjoy guys.
LINK
So here\'s a filterscript I have fount, however, I have tweaked it a little. So I don\'t take a majority of credit. Only a little. Rest goes to the owner. I\'d appreciate some rep in return for the work I put into it. However, that is your choice. (I don\'t even know if I can ask for rep, quite new to SA-MP forums :P) - Enjoy guys.
LINK
Code:
/*|____________________________________________________|*
*|--------------------[LUMBER SYSTEM]-----------------|*
*|---------------------[By:Lynnstrum]-----------------|*
*|____________________________________________________|*/
#include <a_samp>
#include <zcmd> // Command Processer used.
#define DIALOG_LUMBER 1000
#define C_WHITE 0xFFFFFFAA
forward LoadLumber(); // Loads the Lumber when the filterscript is initiated.
forward SaveLumber(); // Saves the lumber when lumber is added or removed.
forward splits(const strsrc[], strdest[][], delimiter);
enum LumberInfo// Information used for the lumber system
{
Text3D:LumberText,//3DText loaded stating the amount of lumber
Lumber
}
new L_Info[LumberInfo];// Shortened way of saying LumberInfor
public OnFilterScriptInit()
{
LoadLumber();// Loads Lumber
return 1;
}
public LoadLumber() {
new LoadCoords[1][24];
new strFromFile2[256];
new str[128];
new File: file = fopen("LSLRP/Jobs/lumber.cfg", io_read);
if (file) {
fread(file, strFromFile2);
splits(strFromFile2, LoadCoords, \'|\');
L_Info[Lumber] = strval(LoadCoords[0]);
format(str, sizeof str, "Lumber Avalible:
{F81414}%d", L_Info[Lumber]);
L_Info[LumberText] = Create3DTextLabel(str, C_WHITE, -62.2114,-1121.7120,1.2945, 10.0, 0);// Lumber
print("Lumber Loaded");
fclose(file);
}
return 1;
}
public SaveLumber() {
new FString[256], File: flocation = fopen("LSLRP/Jobs/lumber.cfg", io_write);//
format(FString, sizeof(FString), "%d", L_Info[Lumber]);
fwrite(flocation, FString);
return fclose(flocation);// Closes the file, after the information above has been Saved.
}
CMD:editlumber(playerid, params[])
{
ShowPlayerDialog(playerid, DIALOG_LUMBER, DIALOG_STYLE_INPUT, "Lumber Settings", "Input the new lumber amount.", "Done", "Cancel");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new string[128+MAX_PLAYER_NAME];
if(dialogid == DIALOG_LUMBER)
{
new lumber = strval(inputtext);
if(response)
{
if(lumber < 0 || lumber > 1000000)
{
SendClientMessage(playerid, C_WHITE, "SYNTAX: {00FF22}Only lumber amounts {FFFFFF}0-1000000 {00FF22}are valid.");
return 1;
}
else {
L_Info[Lumber] = lumber;
format(string, sizeof string, "Lumber Avalible
{F81414}%d", L_Info[Lumber]);
Update3DTextLabelText(L_Info[LumberText], C_WHITE, string);
SaveLumber();
}
}
}
return 1;
}
public splits(const strsrc[], strdest[][], delimiter)
{
new i, li;
new aNum;
new len;
while(i <= strlen(strsrc)){
if(strsrc[i]==delimiter || i==strlen(strsrc)){
len = strmid(strdest[aNum], strsrc, li, i, 128);
strdest[aNum][len] = 0;
li = i+1;
aNum++;
}
i++;
}
return 1;
}


