Plate Number
#1

PHP код:
CMD:numplate(playeridparams[])
{
    new 
txt[16];
    if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid0xFF0000AA"A driver needs the command for his usage to be!");
    if(
isnull(txt)) return SendClientMessage(playerid0xFF0000AA"Usage: /numplate [new numplate]");
    if(!(
strlen(txt) < 19)) return SendClientMessage(playerid0xFF0000AA"Character one needs at least 3, at most 18 for the registration number to be.");
    new 
vehicleid GetPlayerVehicleID(playerid);
    new 
Float:p[4];
    
GetVehiclePos(vehicleidp[0], p[1], p[2]);
    
GetVehicleZAngle(vehicleidp[3]);
    
SetVehicleNumberPlate(vehicleidtxt);
    
pData[playerid][NumPlate] = txt;
    
SetVehiclePos(vehicleidp[0], p[1], p[2]);
    
SetVehicleZAngle(vehicleidp[3]);
    
PutPlayerInVehicle(playeridvehicleid0);
    new 
string[144];
    
format(string144"You rewrote the registration number of your vehicle successfully: '%s'"txt);
    
SendClientMessage(playerid0x33AA33FFstring);
    new 
query[256];
    
mysql_format(mysqlquerysizeof(query), "UPDATE `accounts` SET `NumPlate`=%s WHERE `Username`='%s'",
    
pData[playerid][NumPlate], Name[playerid]);
    
mysql_tquery(mysqlquery"""");
    return 
1;

Error:
: error 006: must be assigned to an array

PHP код:
pData[playerid][NumPlate] = txt
Reply
#2

Use strcpy
Add this on top of the script.
PHP код:
#if !defined strcpy
    #define strcpy(%0,%1) strcat((%0[0] = EOS, %0), %1)
#endif 
PHP код:
pData[playerid][NumPlate] = txt
Replace with:

PHP код:
strcpy(pData[playerid][NumPlate], txtsizeof(txt)); 
Also, Are you sure pData[playerid][NumPlate] is a string?
Reply
#3

PHP код:
new numplate [10];
format(numplate,sizeof(numplate),"%s",txt);
pData[playerid][NumPlate] = numplate;
// Or maybe
format(pData[playerid][NumPlate],10,"%s",text); 
Reply
#4

Alright thanks, But any idea whats wrong with this command cuz every time i use this command it respawn my vehicle but doesn't change my vehicle plate number.

PHP код:
CMD:numplate(playeridparams[])
{
    new 
txt[16];
    if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid0xFF0000AA"A driver needs the command for his usage to be!");
    if(
isnull(txt)) return SendClientMessage(playerid0xFF0000AA"Usage: /numplate [new numplate]");
    if(!(
strlen(txt) < 19)) return SendClientMessage(playerid0xFF0000AA"Character one needs at least 3, at most 18 for the registration number to be.");
    new 
vehicleid GetPlayerVehicleID(playerid);
    new 
Float:p[4];
    
GetVehiclePos(vehicleidp[0], p[1], p[2]);
    
GetVehicleZAngle(vehicleidp[3]);
    
SetVehicleNumberPlate(vehicleidtxt);
    
format(pData[playerid][NumPlate],16,"%s",txt);
    
SetVehicleToRespawn(vehicleid);
    
SetVehiclePos(vehicleidp[0], p[1], p[2]);
    
SetVehicleZAngle(vehicleidp[3]);
    
PutPlayerInVehicle(playeridvehicleid0);
    new 
string[144];
    
format(string144"You rewrote the registration number of your vehicle successfully: '%s'"txt);
    
SendClientMessage(playerid0x33AA33FFstring);
    new 
query[256];
    
mysql_format(mysqlquerysizeof(query), "UPDATE `accounts` SET `NumPlate`=%s WHERE `Username`='%s'",
    
pData[playerid][NumPlate], Name[playerid]);
    
mysql_tquery(mysqlquery"""");
    return 
1;

EDIT:

So, i found out i am doing something wrong on mysql.
Is this wrong way to save num plate ?

PHP код:
new query[256];
    
mysql_format(mysqlquerysizeof(query), "UPDATE `accounts` SET `NumPlate`=%s WHERE `Username`='%s'",
    
pData[playerid][NumPlate], Name[playerid]);
    
mysql_tquery(mysqlquery""""); 
Reply
#5

I get this from mysql.log

PHP код:
[13:22:13] [DEBUGmysql_tquery connection1query"UPDATE accounts SET `NumPlate`=123a WHERE `Username`='AleX'"callback"(null)"format"(null)"
[13:22:13] [DEBUGCMySQLQuery::Execute[] - starting query execution
[13:22:13] [ERRORCMySQLQuery::Execute[] - (error #1054) Unknown column '123a' in 'field list'
[13:22:13] [DEBUGCMySQLQuery::Execute[] - error will be triggered in OnQueryError 
Reply
#6

You have to respawn the vehicle inorder the change of Number plate to take place.

https://sampwiki.blast.hk/wiki/SetVehicleNumberPlate
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)