SA-MP Forums Archive
Reading from 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)
+--- Thread: Reading from file (/showthread.php?tid=293454)



Reading from file - wumpyc - 28.10.2011

Hey thats the code i made...
PHP Code:
public OnGameModeInit()
{
    
ServerRestarting=0;
    new 
File:ftw=fopen("vehicles.txt"io_append),string[4000];
    
SetGameModeText("Wum Mode V.0");
    
AddPlayerClass(01958.37831343.157215.3746269.1425000000);
    
AddPlayerClass(451958.37831343.157215.3746269.1425000000);
     
fread(ftwstring);
    return 
1;
}
CMD:veh(playerid,params[])
{
    new 
vehidFloat:xFloat:yFloat:zFloat:rotFile:ftw=fopen("vehicles.txt"io_append),vehicles[300];
    if(
sscanf(params,"i",vehid)) return SendClientMessage(playerid,0xFF0000FF,"USAGE:/veh [vehicleid]");
    
GetPlayerPos(playerid,x,y,z);
    
GetPlayerFacingAngle(playerid,rot);
    
AddStaticVehicle(vehid,x,y,z,rot,0,0);
    
format(vehicles,sizeof(vehicles),"    AddStaticVehicle(%d,%f,%f,%f,%f,0,0);\r\n",vehid,x,y,z,rot);
    
fwrite(ftw,vehicles);
    
fclose(ftw);
    return 
1;

But..it doesnt works..i mean on restart static vehicles dont add...help?


Re: Reading from file - wumpyc - 28.10.2011

COMEON anyone -.-


Re: Reading from file - FUNExtreme - 28.10.2011

pawn Code:
public OnGameModeInit()
{
    new File:ftw=fopen("vehicles.txt", io_append),string[4000];
    fread(ftw, string); <=================================== What are you reading?
    return 1;
}
What I see is that you are trying to read the whole file like it would then be part of your code. Let me say this: "It won't work... EVER". It is more complex than that, the search function will get you there if you feel up to it!


Re: Reading from file - wumpyc - 28.10.2011

so what can i doOnly way is that i codes from vehicles.txt to gm by myself or wut?


Re: Reading from file - Pinguinn - 28.10.2011

AFAIK you can't include content of a file directly


Re: Reading from file - Tigerkiller - 28.10.2011

take a look into your includes there are on that make it