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(file, strFromFile2);
Split(strFromFile2, arrCoords, ',');
strmid(cid[idx], arrCoords[0], 0, strlen(arrCoords[0]),255);
strmid(cplate[idx], arrCoords[1], 0, strlen(arrCoords[1]),255);
SetVehicleNumberPlate(cid[idx],cplate[idx]);
idx++;
}
fclose(file);
}
return 1;
}
public SavePlate(v, inputtext[])
{
new entry[256];
format(entry, sizeof(entry), "%s,%s\n",v,inputtext);
new File:hFile;
hFile = fopen("CarPlate/carplate.cfg", io_append);
fwrite(hFile, entry);
fclose(hFile);
}
if(strcmp(cmd, "/carplate", true) == 0)
{
if(IsPlayerConnected(playerid))
{ new cid = GetPlayerVehicleID(playerid);
if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_GREY, " You havent logged in yet !");
return 1;
}
if(PlayerInfo[playerid][pCarKey] == 0)
{
SendClientMessage(playerid, COLOR_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(playerid, COLOR_GRAD2, "USAGE: /carplate [plate]");
return 1;
}
if(PlayerInfo[playerid][pCarKey]==0 && PlayerInfo[playerid][pAdmin] < 1337)
{
SendClientMessage(playerid, COLOR_GRAD2, " You don't own a car! ");
return 1;
}
format(string, sizeof(string), "Your new carplate is: %s",result);
SendClientMessage(playerid, COLOR_WHITE, string);
SetVehicleNumberPlate(cid, result);
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;
}
public SavePlate(v, inputtext[])
{
new entry[256];
format(entry, sizeof(entry), "CarPlate/carplate%d.cfg",v);
new File:test;
if(!fexist(entry)) test = fopen(entry, io_readwrite), fclose(test);
new File:hFile;
hFile = fopen(entry, io_write);
fwrite(hFile, inputtext);
fclose(hFile);
}
Yes, excatly.
If you need any help, I can give you the code for the LoadCars, in 1 or two days, because I am very busy. |
public LoadPlate()
{
for(new i=0; i<MAX_VEHICLES; i++)
{
new arrCoords[20][64];
new strFromFile2[256];
new cplate[512];
new cid[512];
new path[70];
format(path, sizeof(path),"CarPlate/carplate%d.cfg", i);
if(fexist(path))
{
new File:file = fopen(path, io_read);
if(file)
{
new idx;
fread(file, strFromFile2);
SetVehicleNumberPlate(i,strFromFile2);
fclose(file);
}
}
}
return 1;
}