Re-loading a file? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Re-loading a file? (
/showthread.php?tid=258086)
Re-loading a file? -
Skylar Paul - 29.05.2011
Well, I currently have two functions (Created by Leth4l)
pawn Code:
stock AddLabelsFromFile(LFileName[])
{
if(!fexist(LFileName)) return 0;
new File:LFile, Line[128], LabelInfo[128], Float:LX, Float:LY, Float:LZ, lTotal = 0;
LFile = fopen(LFileName, io_read);
while(fread(LFile, Line))
{
if(Line[0] == '/' || isnull(Line)) continue;
unformat(Line, "p<,>s[128]fff", LabelInfo,LX,LY,LZ);
CreateDynamic3DTextLabel(LabelInfo, 0xFFFFFFFF, LX, LY, LZ, 100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);
lTotal++;
}
fclose(LFile);
return lTotal;
}
stock AddLabelToFile(LFileName[], LabelInfo[], Float:LX, Float:LY, Float:LZ)
{
new File:LFile, Line[128];
format(Line, sizeof(Line), "%s,%.2f,%.2f,%.2f\r\n",LabelInfo, LX, LY, LZ);
LFile = fopen(LFileName, io_append);
fwrite(LFile, Line);
fclose(LFile);
return 1;
}
Which are used in my dynamic 3DTextLabel system, which works perfectly; Now, i'm wondering if there's a way to make a reload command so it would destroy the pickups in the file, and then reload them.
Here's my add command:
pawn Code:
COMMAND:add
(playerid, params
[]) //Fixed by Frederick Wright - http://www.fwright.com{ new mapicon_id,
mapicon_color,
Float:MapIconX,
Float:MapIconY,
Float:MapIconZ,
vModel,
Float:VX,
Float:VY,
Float:VZ,
Float:VA,
vColor1,
vColor2;
/*snip*/ else if(strcmp(params,
"3DTextLabel", true,
11) == 0) { strdel(params,
0,
11);
new LabelDesc
[128],
Float:YourPos
[3];
if(sscanf
(params,
"s[128]", LabelDesc
)) { UsageMessage
(playerid,
"Add 3DTextLabel",
"[Text]",
"Creates a permanent 3DTextLabel viewable by all players at your position.");
return 1;
} if(PVar
[playerid
][AuthLvl
] >= 3) { GetPlayerPos
(playerid, YourPos
[0], YourPos
[1], YourPos
[2]);
AddLabelToFile
(LABEL_FILE_NAME, LabelDesc, YourPos
[0], YourPos
[1], YourPos
[2]);
CreateDynamic3DTextLabel
(LabelDesc, 0xFFFFFFFF, YourPos
[0], YourPos
[1], YourPos
[2],
100.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID,
0,
-1,
-1,
-1,
100.0);
printf("[+] 3DTextLabel created at %f, %f, %f | Description: %s", YourPos
[0], YourPos
[1], YourPos
[2], LabelDesc
);
} else return AuthError
(playerid,
3);
} else { UsageMessage
(playerid,
"Add",
"[Parameters]",
"MapIcon, Vehicle, Pickup, 3DTextLabel");
return 1;
} return 1;
}
Re: Re-loading a file? -
Calgon - 29.05.2011
Do you mean that you want to clear the file and start over or to destroy all active pickups and spawn them again based on what's in your pickups file?