[y_ini / saving / vehicles] my problems with saving y_ini
#1

Hello EveryOne
i Want Help / Y_ini Saving The Vehicles
this my code its working with out y_ini saving :/
PHP код:
CMD:cars(playeridparams[])
{
    if(
sscanf(params"i"params[0]))
        return 
SendClientMessage(playerid, -1"usage: /cars [id 1-7].");
    switch(
params[0])
    {
        case 
1:
        {
            if(
GetPlayerMoney(playerid) < 1200000)
                return 
SendClientMessage(playerid0"You don't have enough cash to buy this car!");
            
GivePlayerMoney(playerid, -1200000);
            new 
Float:p[4];
            
GetPlayerPos(playeridp[0], p[1], p[2]);
            
GetPlayerFacingAngle(playeridp[3]);
            
CreateVehicle(541p[0], p[1], p[2], p[3]+90, -1, -19999999);
        }
        case 
2:
        {
            if(
GetPlayerMoney(playerid) < 1900000)
                return 
SendClientMessage(playerid0"You don't have enough cash to buy this car!");
            
GivePlayerMoney(playerid, -1900000);
            new 
Float:p[4];
            
GetPlayerPos(playeridp[0], p[1], p[2]);
            
GetPlayerFacingAngle(playeridp[3]);
            
CreateVehicle(411p[0], p[1], p[2], p[3]+90, -1, -19999999);
        }
        case 
3:
        {
            if(
GetPlayerMoney(playerid) < 4000000)
                return 
SendClientMessage(playerid0"You don't have enough cash to buy this car!");
            
GivePlayerMoney(playerid, -4000000);
            new 
Float:p[4];
            
GetPlayerPos(playeridp[0], p[1], p[2]);
            
GetPlayerFacingAngle(playeridp[3]);
            
CreateVehicle(494p[0], p[1], p[2], p[3]+90, -1, -19999999);
        }
        case 
4:
        {
            if(
GetPlayerMoney(playerid) < 22000)
                return 
SendClientMessage(playerid0"You don't have enough cash to buy this car!");
            
GivePlayerMoney(playerid, -22000);
            new 
Float:p[4];
            
GetPlayerPos(playeridp[0], p[1], p[2]);
            
GetPlayerFacingAngle(playeridp[3]);
            
CreateVehicle(409p[0], p[1], p[2], p[3]+90, -1, -19999999);
        }
        case 
5:
        {
            if(
GetPlayerMoney(playerid) < 460000)
                return 
SendClientMessage(playerid0"You don't have enough cash to buy this car!");
            
GivePlayerMoney(playerid, -460000);
            new 
Float:p[4];
            
GetPlayerPos(playeridp[0], p[1], p[2]);
            
GetPlayerFacingAngle(playeridp[3]);
            
CreateVehicle(560p[0], p[1], p[2], p[3]+90, -1, -19999999);
        }
        case 
6:
        {
            if(
GetPlayerMoney(playerid) < 600000)
                return 
SendClientMessage(playerid0"You don't have enough cash to buy this car!");
            
GivePlayerMoney(playerid, -600000);
            new 
Float:p[4];
            
GetPlayerPos(playeridp[0], p[1], p[2]);
            
GetPlayerFacingAngle(playeridp[3]);
            
CreateVehicle(506p[0], p[1], p[2], p[3]+90, -1, -19999999);
        }
        case 
7:
        {
            if(
GetPlayerMoney(playerid) < 5000000)
                return 
SendClientMessage(playerid0"You don't have enough cash to buy this car!");
            
GivePlayerMoney(playerid, -5000000);
            new 
Float:p[4];
            
GetPlayerPos(playeridp[0], p[1], p[2]);
            
GetPlayerFacingAngle(playeridp[3]);
            
CreateVehicle(521p[0], p[1], p[2], p[3]+90, -1, -19999999);
        }
    }
    return 
true;

now i want it saving with y_ini
PHP код:
#define CarPath "Cars/%s.ini"
enum PlayercInfo
{
     
PlayerName[20],
     
Car1Model,
     
Float:CarX1,
     
Float:CarY1,
     
Float:CarZ1,
     
Float:CarA1,
     
Car2Model,
     
Float:CarX2,
     
Float:CarY2,
     
Float:CarZ2,
     
Float:CarA2,
     
Car3Model,
     
Float:CarX3,
     
Float:CarY3,
     
Float:CarZ3,
     
Float:CarA3,
}
new 
cInfo[MAX_PLAYERS][PlayercInfo]; 
PHP код:
stock Path(playerid//Will create a new stock so we can easily use it later to load/save user's data in user's path
{
    new 
str[128],name[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,name,sizeof(name));
    
format(str,sizeof(str),CarPath,name);
    return 
str;

can somone help me with complete the saving float car and vehicles id please ?
+rep
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=175565

You could at least attempt to do it before asking for help... you haven't even 'tried' to save it with y_ini.

You can either:
1. Stop being so lazy and learn how to script for yourself.
2. Go to a script request thread.
Reply
#3

Quote:
Originally Posted by Threshold
Посмотреть сообщение
https://sampforum.blast.hk/showthread.php?tid=175565

You could at least attempt to do it before asking for help... you haven't even 'tried' to save it with y_ini.

You can either:
1. Stop being so lazy and learn how to script for yourself.
2. Go to a script request thread.
i cant understand :/
but im made this CMD Cars
but i dont know how to saving it
i can only save somthings smail like death / kill
not car + float :/
please any one help me +rep
Reply
#4

hello i dont test this but maybe can help you

http://pastebin.com/DnKpk19W
Reply
#5

Quote:
Originally Posted by Golf
Посмотреть сообщение
hello i dont test this but maybe can help you

http://pastebin.com/DnKpk19W
have 2 errors only
PHP код:
D:\da\filterscripts\Copy (3of car.pwn(158) : warning 203symbol is never used"LoadVehicles"
D:\da\filterscripts\Copy (3of car.pwn(158) : warning 203symbol is never used"SaveVehicles" 
PHP код:
SaveVehicles()
{
        new 
filestring[125];
        new 
Filevfile fopen("vehicles.txt"io_write);
        for(new 
vehicleid 1;vehicleid<MAX_VEH;vehicleid++)
        {
         if(
cInfo[vehicleid][Car1Model] != 0)
                 {
                        
format(filestringsizeof(filestring), "%i,%f\n"// ... continue
                        
cInfo[vehicleid][Car1Model],
                        
cInfo[vehicleid][CarX1// float
                        
);
                        
fwrite(vfilefilestring);
                  }
                }
                
fclose(vfile);
}
LoadVehicles()
{
        if(
fexist("vehicles.txt"))
        {
            new 
string[125];
        new 
SplitDiv[40][32];
                new 
filestring[275];
                new 
Filefile fopen(VEHICLE_FILE_io_read);
                if (
file)
                {
                for(new 
vehicleid 1;vehicleid<MAX_VEH;vehicleid++)
                        {
                        
fread(filefilestring);
                                
split(filestringSplitDiv',');
                                
cInfo[vehicleid][Car1Model] = strval(SplitDiv[0]);
                                
cInfo[vehicleid][CarX1] = floatstr(SplitDiv[1]);
                        }
                }
                
fclose(file);
        }

Reply
#6

This is warning not error you never used load and save vehicles,if you use them somewhere in script you won't get warnings anymore
Reply
#7

Quote:
Originally Posted by MikE1990
Посмотреть сообщение
This is warning not error you never used load and save vehicles,if you use them somewhere in script you won't get warnings anymore
what :/ ??
Reply
#8

Код:
D:\da\filterscripts\Copy (3) of car.pwn(158) : warning 203: symbol is never used: "LoadVehicles" 
D:\da\filterscripts\Copy (3) of car.pwn(158) : warning 203: symbol is never used: "SaveVehicles"
This means you never used LoadVehicles() and SaveVehicles() in your script.
Reply
#9

i made it onplayerconnect and disconect
but have much errors :/
PHP код:
public OnPlayerConnect(playerid)
{
SaveVehicles()
{
        new 
filestring[125];
        new 
Filevfile fopen("vehicles.txt"io_write);
        for(new 
vehicleid 1;vehicleid<MAX_VEH;vehicleid++)
        {
         if(
cInfo[vehicleid][Car1Model] != 0)
                 {
                        
format(filestringsizeof(filestring), "%i,%f\n"// ... continue
                        
cInfo[vehicleid][Car1Model],
                        
cInfo[vehicleid][CarX1// float
                        
);
                        
fwrite(vfilefilestring);
                  }
                }
                
fclose(vfile);
                return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
LoadVehicles()
{
        if(
fexist("vehicles.txt"))
        {
            new 
string[125];
        new 
SplitDiv[40][32];
                new 
filestring[275];
                new 
Filefile fopen(VEHICLE_FILE_io_read);
                if (
file)
                {
                for(new 
vehicleid 1;vehicleid<MAX_VEH;vehicleid++)
                        {
                        
fread(filefilestring);
                                
split(filestringSplitDiv',');
                                
cInfo[vehicleid][Car1Model] = strval(SplitDiv[0]);
                                
cInfo[vehicleid][CarX1] = floatstr(SplitDiv[1]);
                        }
                }
                
fclose(file);
                return 
1;

Reply
#10

Oh no,you just need to call them not create them inside try this:
Код:
public OnPlayerConnect(playerid) 
{ 
    LoadVehicles();
    return 1;
}
public OnPlayerDisconnect(playerid, reason) 
{ 
    SaveVehicles();
    return 1;
}

SaveVehicles() 
{ 
        new filestring[125]; 
        new File: vfile = fopen("vehicles.txt", io_write); 
        for(new vehicleid = 1;vehicleid<MAX_VEH;vehicleid++) 
        { 
         if(cInfo[vehicleid][Car1Model] != 0) 
                 { 
                        format(filestring, sizeof(filestring), "%i,%f\n", // ... continue 
                        cInfo[vehicleid][Car1Model], 
                        cInfo[vehicleid][CarX1] // float 
                        ); 
                        fwrite(vfile, filestring); 
                  } 
                } 
                fclose(vfile); 
                return 1; 
} 

LoadVehicles() 
{ 
        if(fexist("vehicles.txt")) 
        { 
            new string[125]; 
        new SplitDiv[40][32]; 
                new filestring[275]; 
                new File: file = fopen(VEHICLE_FILE_, io_read); 
                if (file) 
                { 
                for(new vehicleid = 1;vehicleid<MAX_VEH;vehicleid++) 
                        { 
                        fread(file, filestring); 
                                split(filestring, SplitDiv, ','); 
                                cInfo[vehicleid][Car1Model] = strval(SplitDiv[0]); 
                                cInfo[vehicleid][CarX1] = floatstr(SplitDiv[1]); 
                        } 
                } 
                fclose(file); 
                return 1; 
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)