Read file help
#1

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:vehxFloat:vehyFloat:vehz;
              
GetVehiclePos(petrucarvehxvehyvehz);
            new 
Float:z_rot
            GetVehicleZAngle
(petrucarz_rot);
            
            new 
File:pos=fopen("petrucar.pos"io_write);
            
format(string256"CreateVehicle(541, %f, %f, %f, %f, 1,2,0);"vehxvehyvehzz_rot);
            
fwrite(posstring);
            
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:vehxFloat:vehyFloat:vehz;
    
GetVehiclePos(petrucarvehxvehyvehz);
    new 
Float:z_rot
    
new string[256]
    
GetVehicleZAngle(petrucarz_rot);
    
format(string256"CreateVehicle(541, %f, %f, %f, %f, 1,2,0);"vehxvehyvehzz_rot);
    while(
fread(posstring))
    {
        
CreateVehicle(541x,y,z,rot,2,1,0);
    }

PHP код:
    if(strcmp(cmd"/mpon"true) == 0)
    {
        if(
PlayerInfo[playerid][pAdmin] == 7)
        {
            
readpetrucar();
        }
    } 
Please help me.
Reply
#2

Can somebody help me ?
Reply
#3

Somebody ?
Reply
#4

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);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)