Read file help - 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: Read file help (
/showthread.php?tid=271175)
[HELP] Fread -
Petru_Me - 23.07.2011
Hi ! I want to make a write/read system. First I make this
PHP код:
if(strcmp(cmd, "/carpark", true) == 0)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
if(strcmp(name,"Petru_Chemp",false) == 0)
{
new Float:vehx, Float:vehy, Float:vehz;
GetVehiclePos(petrucar, vehx, vehy, vehz);
new Float:z_rot
GetVehicleZAngle(petrucar, z_rot);
new File:pos=fopen("petrucar.pos", io_write);
format(string, 256, "CreateVehicle(541, %f, %f, %f, %f, 1,2,0);", vehx, vehy, vehz, z_rot);
fwrite(pos, string);
fclose(pos);
}
}
And now I want to read this file and take from it x,y,z,rot coords . I try this but I don't know to continue
PHP код:
readpetrucar()
{
new File:pos=fopen("petrucar.pos", io_read);
new Float:vehx, Float:vehy, Float:vehz;
GetVehiclePos(petrucar, vehx, vehy, vehz);
new Float:z_rot
new string[256]
GetVehicleZAngle(petrucar, z_rot);
format(string, 256, "CreateVehicle(541, %f, %f, %f, %f, 1,2,0);", vehx, vehy, vehz, z_rot);
while(fread(pos, string))
{
CreateVehicle(541, x,y,z,rot,2,1,0);
}
}
PHP код:
if(strcmp(cmd, "/mpon", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] == 7)
{
readpetrucar();
}
}
Please help me.
Re: Read file help -
Petru_Me - 23.07.2011
Can somebody help me ?
Re: Read file help -
Petru_Me - 24.07.2011
Somebody ?
Re: Read file help -
MadeMan - 24.07.2011
pawn Код:
readpetrucar()
{
new model, Float:vehx, Float:vehy, Float:vehz, Float:z_rot;
new string[256];
new File:pos=fopen("petrucar.pos", io_read);
while(fread(pos, string))
{
if(!string[0]) continue;
if(strcmp(string, "CreateVehicle(", false, 14) == 0)
{
sscanf(string[14], "dffff", model, vehx, vehy, vehz, z_rot);
CreateVehicle(model, vehx, vehy, vehz, z_rot,2,1,0);
}
}
fclose(pos);
}