Scripting help (Vehicle system)
#1

I've been scripting for years but i'm clueless as to why this script doesn't work proparly. Propably a simple mistake somewhere... So my problem is that GetVehicleSQLID isn't working i did a debug using command /carsql that i made. I've taken the relevant code out of my script to get some help on this.

here is the debug command (I use this in a car) :
and it returned SERVER: Command does not exist

Код:
command(carsql, playerid, params[])
{
	new string[100];
    new vehid = GetPlayerVehicleID(playerid);
	
	format(string, sizeof(string), "The sql id of this vehicle is: %d. ", GetVehicleSQLID(vehid));
	SendClientMessage(playerid, COLOR_WHITE, string);
	
	
	
	return 1;
}
enum:

Код:
enum VehicleStats{
id,
perm,
model,
Float:vx,
Float:vy,
Float:vz,
Float:va,
c1,
c2,
plate[8],
lock,
GameID
};
new Vehicle[MAX_VEHICLE][VehicleStats];
Vehilce spawning:

Код:
 
stock LoadDynamicVehicles()
{
	new Str[128], VehicleID, i = 0;
	
    mysql_query("SELECT * FROM `vehicles`");
    mysql_store_result();
    if(mysql_num_rows() != 0)
    {
        while(mysql_fetch_row(Str))
        {
            sscanf(Str, "p<|>iiiffffiis[10]", VehicleID, Vehicle[i][perm], Vehicle[i][model], Vehicle[i][vx], Vehicle[i][vy], Vehicle[i][vz], Vehicle[i][va], Vehicle[i][c1], Vehicle[i][c2], Vehicle[i][plate]);

            
			
			SetVehicleNumberPlate(Vehicle[i][GameID] = CreateVehicle(Vehicle[i][model], Vehicle[i][vx], Vehicle[i][vy], Vehicle[i][vz], Vehicle[i][va], Vehicle[i][c1], Vehicle[i][c2], -1), Vehicle[i][plate]);
            SetVehicleToRespawn(i);
			Vehicle[i][id] = VehicleID;
            i++;
			
		}
    }
    mysql_free_result();
    printf("--- %i vehicle(s) loaded from the MySQL Database. ---", i);
	return 1;
}
GetVehicleSQLID(vehid):

Код:
GetVehicleSQLID(vehid)
{
   new result;
   for (new i = 0; i < MAX_VEHICLES; i++)
   {
	  if(vehid == Vehicle[i][GameID])
	  {
		  result = i;
	  }
   }
   return result;
}
I appreciate all the help you guys give. I never really ask for it as i seem to solve problems rather well but this one has got me.

My main questionm is: What is causing GetVehicleSQLID to not work?


Darren (Dazman14)
Reply
#2

Its not the function that doesnt work its command , have you tried CMD:carsql(playerid,params[])...?
Reply
#3

Quote:
Originally Posted by Dziugsas
Посмотреть сообщение
Its not the function that doesnt work its command , have you tried CMD:carsql(playerid,params[])...?
There is no difference to my command setup than the one above. I already have working commands. The script has a problem getting the cars sql ID. Even though the function as you said looks fine.
Reply
#4

if your cmd is working why do you get SERVER: Command does not exist?
Reply
#5

Quote:
Originally Posted by Dziugsas
Посмотреть сообщение
if your cmd is working why do you get SERVER: Command does not exist?
I have working commands around it. Such as /createcar. The script just hits problems when getting the vehicle sql id from the gameid. Even though its set up correctly. There must be a problem somwhere in my code to cause gathering the ID to fail causing the command to return Command Does not exist.


[GameID] is linked to that particular car on spawning from database. So i don't understand when it finds the game id by going through the For loop in GetVehicleSQLID it should return the SQL id as the result but instead doesn't function.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)