30.03.2011, 18:55
So, I made a vehicle script.
I made this command - /setplate.
After I setplate I respawn the vehicle and I see the number plate just the way I need that.
Then again, if I restart the server, it reloads the cars and the number plates. But it doesn't show the number plate correctly. For example, if I have the license plate 'ABCDE', it shows 'AYYDE'.
Second and third letter are Y's with some weirs dots on top of it.
Another example - The license plate is 'POLICE', it shows 'PYYICE'
SaveSQLCar and LoadSQLCars codes:
The number plates in the SQL is correct, but when I restart the server, the number plate's second and third letter render wrongly.
It also happens when I manually set the number plate of the vehicle in the SQL.
Any ideas what that is about?
Field type is char, length 64, encoding (or whatever that is) is latin1_swedish_ci.
Maybe the encoding is the problem, if that is so, please tell me what to use.
Greetings,
666
I made this command - /setplate.
Код:
if(strcmp(cmd, "/setplate", true) == 0) { if(PlayerInfo[playerid][pAdmin] >= 6) { GetPlayerName(playerid, sendername, sizeof(sendername)); new length = strlen(cmdtext); while ((idx < length) && (cmdtext[idx] <= ' ')) { idx++; } new offset = idx; new result[256]; 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: /setplate [string]"); return 1; } new mycar = GetPlayerVehicleID(playerid); //SetVehicleNumberPlate(GetPlayerVehicleID(playerid), result); memcpy(CarInfo[mycar][cPlate], result, 0, 32*4, 32*4); format(string, 256, "Car %d, Plate is now %s", mycar, CarInfo[mycar][cPlate]); SetVehicleNumberPlate(mycar, result); SendClientMessage(playerid, COLOR_WHITE, string); SaveSQLCar(mycar); } return 1; }
Then again, if I restart the server, it reloads the cars and the number plates. But it doesn't show the number plate correctly. For example, if I have the license plate 'ABCDE', it shows 'AYYDE'.
Second and third letter are Y's with some weirs dots on top of it.
Another example - The license plate is 'POLICE', it shows 'PYYICE'
SaveSQLCar and LoadSQLCars codes:
Код:
public SaveSQLCar(idx) { new sql[384]; format(sql, sizeof(sql), "UPDATE cars SET model=%d,x=%f,y=%f,z=%f,angle=%f,color1=%d,color2=%d,owner='%s',plate='%s',description='%s',price=%d,owned=%d,locked=%d,respawnable=%d WHERE id=%d", CarInfo[idx][cModel],// CarInfo[idx][cLocationx],// CarInfo[idx][cLocationy],// CarInfo[idx][cLocationz],// CarInfo[idx][cAngle],// CarInfo[idx][cColorOne],// CarInfo[idx][cColorTwo],// CarInfo[idx][cOwner],// CarInfo[idx][cPlate],// CarInfo[idx][cDescription],// CarInfo[idx][cValue],// CarInfo[idx][cOwned],// CarInfo[idx][cLock], CarInfo[idx][cRespawnable], idx ); //if (DEBUG) SQLLog(sql); samp_mysql_query(sql); return 1; }
Код:
public LoadSQLCars() { MySQLCheckConnection(); new sql[64], fields[25][40], row[255]; new Float:park_x, Float:park_y, Float:park_z, Float:park_a; // new owner[MAX_PLAYER_NAME]; format(sql, sizeof(sql), "SELECT COUNT(*) FROM cars"); samp_mysql_query(sql); //if (DEBUG) SQLLog(sql); samp_mysql_store_result(); samp_mysql_fetch_row(row); totalcars = strval(row); //samp_mysql_free_result(); for (new i=1; i<=totalcars; i++) { format(sql, sizeof(sql), "SELECT * FROM cars WHERE id=%d", i); samp_mysql_query(sql); //if (DEBUG) SQLLog(sql); samp_mysql_store_result(); samp_mysql_fetch_row(row); split(row, fields, '|'); //samp_mysql_free_result(); // carid = strval(fields[0]); CarInfo[i][cModel] = strval(fields[1]); CarInfo[i][cLocationx] = floatstr(fields[2]); CarInfo[i][cLocationy] = floatstr(fields[3]); CarInfo[i][cLocationz] = floatstr(fields[4]); CarInfo[i][cAngle] = floatstr(fields[5]); park_x = floatstr(fields[6]); park_y = floatstr(fields[7]); park_z = floatstr(fields[8]); park_a = floatstr(fields[9]); if (park_x != 0 && park_y != 0 && park_z != 0) { CarInfo[i][cLocationx] = park_x; CarInfo[i][cLocationy] = park_y; CarInfo[i][cLocationz] = park_z; CarInfo[i][cAngle] = park_a; } CarInfo[i][cColorOne] = strval(fields[10]); CarInfo[i][cColorTwo] = strval(fields[11]); CarInfo[i][cOwned] = strval(fields[12]); memcpy(CarInfo[i][cOwner], fields[13], 0, MAX_PLAYER_NAME*4, MAX_PLAYER_NAME*4); memcpy(CarInfo[i][cDescription], fields[17], 0, MAX_PLAYER_NAME*4, MAX_PLAYER_NAME*4); CarInfo[i][cValue] = strval(fields[18]); memcpy(CarInfo[i][cPlate], fields[15], 0, MAX_PLAYER_NAME*4, MAX_PLAYER_NAME*4); CarInfo[i][cFaction] = strval(fields[14]); CarInfo[i][cType] = strval(fields[16]); CarInfo[i][cRespawnable] = strval(fields[19]); CarInfo[i][cRespawnTime] = 0; CarInfo[i][cLock] = strval(fields[20]); // Locked CarInfo[i][cHouse] = strval(fields[22]); if (carsreloaded==0) SetVehicleNumberPlate(AddStaticVehicleEx(CarInfo[i][cModel], CarInfo[i][cLocationx], CarInfo[i][cLocationy], CarInfo[i][cLocationz]+0.5, CarInfo[i][cAngle], CarInfo[i][cColorOne], CarInfo[i][cColorTwo], CarInfo[i][cValue]), CarInfo[i][cPlate]) else CarRespawn(i); new engine, lights, alarm, doors, bonnet, boot, objective; GetVehicleParamsEx(i, engine, lights, alarm, doors, bonnet, boot, objective); SetVehicleParamsEx(i, 0, 0, 0, 0, 0, 0, 0); SetVehicleNumberPlate(i, CarInfo[i][cPlate]); // printf("Car: %d, Model: %d, Owner: %s, Type: %d, Desc: %s", i, CarInfo[i][cModel], CarInfo[i][cOwner], CarInfo[i][cType], CarInfo[i][cDescription]); } carsreloaded++; format(row, sizeof(row), "LoadSQLCars(): %d cars loaded", totalcars); printf(row); }
It also happens when I manually set the number plate of the vehicle in the SQL.
Any ideas what that is about?
Field type is char, length 64, encoding (or whatever that is) is latin1_swedish_ci.
Maybe the encoding is the problem, if that is so, please tell me what to use.
Greetings,
666