Reading from file
#1

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?
Reply
#2

COMEON anyone -.-
Reply
#3

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!
Reply
#4

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

AFAIK you can't include content of a file directly
Reply
#6

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


Forum Jump:


Users browsing this thread: 1 Guest(s)