[HELP]Saving License Plate
#1

Hi,
Can somenody help me doing this right:
I have a saving/loading License Plate system.
The LoadPlate() function is working fine, but the SavePlate not.
It make it like this
268, Nick
268, asdfg
268, 132
.
.
.
I just want that the Vehicle Id won't repeat anymore, but update.
Here is my LoadPlate func :
PHP код:
public LoadPlate()
{
    new 
arrCoords[20][64];
    new 
strFromFile2[256];
    new 
cplate[512];
    new 
cid[512];
    new 
File:file fopen("CarPlate/carplate.cfg"io_read);
    if (
file)
    {
        new 
idx;
        while (
idx 256)
        {
            
fread(filestrFromFile2);
            
Split(strFromFile2arrCoords',');
            
strmid(cid[idx], arrCoords[0], 0strlen(arrCoords[0]),255);
            
strmid(cplate[idx], arrCoords[1], 0strlen(arrCoords[1]),255);
            
SetVehicleNumberPlate(cid[idx],cplate[idx]);
            
idx++;
        }
        
fclose(file);
    }
    return 
1;

SavePlate:
PHP код:
public SavePlate(vinputtext[])
{
    new 
entry[256];
    
format(entrysizeof(entry), "%s,%s\n",v,inputtext);
    new 
File:hFile;
    
hFile fopen("CarPlate/carplate.cfg"io_append);
    
fwrite(hFileentry);
    
fclose(hFile);

and /carplate command:
PHP код:
    if(strcmp(cmd"/carplate"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {    new 
cid GetPlayerVehicleID(playerid);
            if(
gPlayerLogged[playerid] == 0)
            {
                
SendClientMessage(playeridCOLOR_GREY"   You havent logged in yet !");
                return 
1;
            }
            if(
PlayerInfo[playerid][pCarKey] == 0)
            {
                
SendClientMessage(playeridCOLOR_GRAD2"You don't own a car");
                return 
1;
            }
            
//GetPlayerName(playerid, sendername, sizeof(sendername));
            
new length strlen(cmdtext);
            while ((
idx length) && (cmdtext[idx] <= ' '))
            {
                
idx++;
            }
            new 
offset idx;
            new 
result[64];
            while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
            {
                
result[idx offset] = cmdtext[idx];
                
idx++;
            }
            
result[idx offset] = EOS;
            if(!
strlen(result))
            {
                
SendClientMessage(playeridCOLOR_GRAD2"USAGE: /carplate [plate]");
                return 
1;
            }
            if(
PlayerInfo[playerid][pCarKey]==&& PlayerInfo[playerid][pAdmin] < 1337)
            {
                
SendClientMessage(playeridCOLOR_GRAD2" You don't own a car! ");
                return 
1;
            }
            
format(stringsizeof(string), "Your new carplate is: %s",result);
            
SendClientMessage(playeridCOLOR_WHITEstring);
            
SetVehicleNumberPlate(cidresult);
            
SavePlate(cid,result);
            
/*new query[64];
            format(query, sizeof(query),"INSERT INTO plate (VehicleID, CarPlate) VALUES ('%d', '%s')", cid,result);
            samp_mysql_query(query);*/
        
}
        return 
1;
    } 
Thank you!
Reply


Messages In This Thread
[HELP]Saving License Plate - by pop.nicku - 07.10.2011, 14:43
Re: [HELP]Saving License Plate - by Jeffry - 07.10.2011, 19:48
Re: [HELP]Saving License Plate - by pop.nicku - 13.10.2011, 11:59
Re: [HELP]Saving License Plate - by whitedragon - 13.10.2011, 12:27
Re: [HELP]Saving License Plate - by Jeffry - 13.10.2011, 16:05
Re: [HELP]Saving License Plate - by pop.nicku - 14.10.2011, 14:06
Re: [HELP]Saving License Plate - by Jeffry - 14.10.2011, 15:46
Re: [HELP]Saving License Plate - by pop.nicku - 14.10.2011, 19:43
Re: [HELP]Saving License Plate - by Jeffry - 18.10.2011, 15:02
Re: [HELP]Saving License Plate - by W-P - 26.09.2012, 13:18

Forum Jump:


Users browsing this thread: 3 Guest(s)