07.10.2011, 14:43
(
Последний раз редактировалось pop.nicku; 07.10.2011 в 15:53.
)
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 :
SavePlate:
and /carplate command:
Thank you!
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(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;
}
PHP код:
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);
}
PHP код:
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;
}