SA-MP Forums Archive
vinfo cmd help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: vinfo cmd help (/showthread.php?tid=608073)



vinfo cmd help - Uberanwar - 27.05.2016

Код:
CMD:vinfo(playerid, params[])
{
	new string[240], vid, loc[30];
	
	format(loc, sizeof(loc), VEHICLE_FILE, vid);

	new model = vInfo[vid][Model];
	new type = vInfo[vid][Type];
	new faction = vInfo[vid][Faction];
	new col1 = vInfo[vid][ColorA];
	new col2 = vInfo[vid][ColorB];
	new plate = vInfo[vid][Plate];
	new siren = vInfo[vid][Siren];

    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "{8EB2D6}SERVER:{FFFFFF} You need to be in a vehicle in order to do this command!");
	if(pInfo[playerid][Admin] < 1) return SendClientMessage(playerid, -1, "{8EB2D6}SERVER:{FFFFFF} You need to be an admin in order to do this command!");

	if(fexist(loc))
	{
		format(string, sizeof(string), "{8EB2D6}SERVER:{FFFFFF} [VID: %d | Model: %d | Type: %d | Faction: %d | Color: %d | Color: %d | Plate: %d | Siren: %d]", vid, model, type, faction, col1, col2, plate, siren);
		SendClientMessage(playerid, -1, string);
		return true;
	}
	else return SendClientMessage(playerid, -1, "{8EB2D6}[INFO]{FFFFFF}: This vehicle is not registered in the database.");
}
I have created & registered vehicles in Vehicles folder, but when I do /vinfo, it says it's not registered although it is. What's seems to be wrong?
define is #define VEHICLE_FILE "Vehicles/%d.ini"


Re: vinfo cmd help - Amunra - 27.05.2016

variable "vid" is zerro..
You not Holds the Vehicle ID !!
Make sure you holds the Vehicle ID using Loop ..

Note : vid = 0;
You must hold Vehicle ID Before Get a Value !!


Re: vinfo cmd help - Dayrion - 27.05.2016

Check at mine /vinfo commands. You required to know the vehicle's ID:
PHP код:
#define red 0xCC0000FF
#define rougeUC "{FF000E}"
CMD:vinfo(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdminlvl] >= 5)
    {
        new 
vehid;
        if(
sscanf(params,"i",vehid)) return SendClientMessage(playeridX11_LIGHT_BLUE_1"/vinfo [id_vehicle]");
        if(
vehid GetVehiclePoolSize() || vehid <= 0) return SendClientMessage(playeridred"[SYSTEM]"rougeUC" Wrong ID.");
        
printf("\n[DEBUG] /vinfo CALLED | Vehicle ID : %i"vehid);
        
printf("[vID] %i"PlayerVehicle[vehid][vID]);
        
printf("[vX] %f",PlayerVehicle[vehid][vX]);
        
printf("[vY] %f",PlayerVehicle[vehid][vY]);
        
printf("[vZ] %f",PlayerVehicle[vehid][vZ]);
        
printf("[vZr] %f",PlayerVehicle[vehid][vZr]);
        
printf("[vColor1] %i",PlayerVehicle[vehid][vColor1]);
        
printf("[vColor2] %i",PlayerVehicle[vehid][vColor2]);
        
printf("[vHealth] %02f",PlayerVehicle[vehid][vHealth]);
        
printf("[vModel] %i",PlayerVehicle[vehid][vModel]);
        
printf("[vPrio] %s",PlayerVehicle[vehid][vPrio]);
        
printf("[vTake] %i",PlayerVehicle[vehid][vTake]);
        
printf("[vPlate] %i",PlayerVehicle[vehid][vPlate]);
        return 
1;
    }
    else return 
SendClientMessage(playeridred"[SYSTEM]"rougeUC" You are not allowed to use this command.");

Also the info vehicle needs to be loaded before this. They are loaded during the gamemode's initialization.
Like this :
PHP код:
for(new GetVehiclePoolSize(); != 0i--)
    {
        if(!
fexist(UserPathV(i)))
        {
            
printf("Vehicle ID : %i"i);
            new 
randomC1randomC2;
            
randomC1 random(100);
            
randomC2 random(100);
            
GetVehicleZAngle(i,PlayerVehicle[i][vZr]);
            
GetVehiclePos(iPlayerVehicle[i][vX], PlayerVehicle[i][vY], PlayerVehicle[i][vZ]);
            
PlayerVehicle[i][vID] = i;
            
PlayerVehicle[i][vColor1] = randomC1;
            
PlayerVehicle[i][vColor2] = randomC2;
            
ChangeVehicleColor(iPlayerVehicle[i][vColor1], PlayerVehicle[i][vColor2]);
            
PlayerVehicle[i][vModel] = GetVehicleModel(i);
            
GetVehicleHealth(iPlayerVehicle[i][vHealth]);
            
PlayerVehicle[i][vTake] = 0;
            
printf("vID : %i"PlayerVehicle[i][vID]);
            
printf("vPos (x,y,z) : %f %f %f - %i"PlayerVehicle[i][vX], PlayerVehicle[i][vY], PlayerVehicle[i][vZ], i);
            
printf("vZr : %f"PlayerVehicle[i][vZr]);
            
printf("Color : %i - %i"PlayerVehicle[i][vColor1], PlayerVehicle[i][vColor2]);
            
printf("vModel : %i"PlayerVehicle[i][vModel]);
            
printf("vHealth : %02f"PlayerVehicle[i][vHealth]);
            
printf("vTake : %i"PlayerVehicle[i][vTake]);
            
printf("vPlate : %i"PlayerVehicle[i][vPlate]);
            new 
INI:File INI_Open(UserPathV(i));
            
INI_WriteInt(File,"vID",PlayerVehicle[i][vID]);
            
INI_WriteFloat(File,"vX",PlayerVehicle[i][vX]);
            
INI_WriteFloat(File,"vY",PlayerVehicle[i][vY]);
            
INI_WriteFloat(File,"vZ",PlayerVehicle[i][vZ]);
            
INI_WriteFloat(File,"vZr",PlayerVehicle[i][vZr]);
            
INI_WriteInt(File,"vColor1",PlayerVehicle[i][vColor1]);
            
INI_WriteInt(File,"vColor2",PlayerVehicle[i][vColor2]);
            
INI_WriteFloat(File,"vHealth",PlayerVehicle[i][vHealth]+1000.0);
            
INI_WriteInt(File,"vModel",PlayerVehicle[i][vModel]);
            
INI_WriteString(File,"vPrio","None");
            
INI_WriteInt(File,"vTake",PlayerVehicle[i][vTake]);
            
INI_WriteInt(File,"vPlate",PlayerVehicle[i][vPlate]);
            
INI_Close(File);
            
printf("\n[FILE] Vehicle ID : %i - Created\n"i);
        }
        else
        {
            new 
chemin[120];
            
//printf("\n--------------------\nStarting to load vehicle id %i", i);
            
format(cheminsizeof(chemin), "/daday/Vehicle/%i.ini"i);
            
INI_ParseFile(chemin"LoadUserV_data", .bExtra true, .extra i);
            
VehicleParams[i][vMotor] = 0;
            
VehicleParams[i][vPhares] = 0;
            
VehicleParams[i][vAlarme] = 0;
            
VehicleParams[i][vLock] = 0;
            
VehicleParams[i][vCapot] = 0;
            
VehicleParams[i][vCoffre] = 0;
            
VehicleParams[i][vObjective] = 0;
            
SetVehicleParamsEx(iVehicleParams[i][vMotor], VehicleParams[i][vPhares], VehicleParams[i][vAlarme], VehicleParams[i][vLock], VehicleParams[i][vCapot], VehicleParams[i][vCoffre], VehicleParams[i][vObjective]);
            
/*printf("\nvID %i", PlayerVehicle[i][vID]);
            printf("vX %f",PlayerVehicle[i][vX]);
            printf("vY %f",PlayerVehicle[i][vY]);
            printf("vZ %f",PlayerVehicle[i][vZ]);
            printf("vZr %f",PlayerVehicle[i][vX]);
            printf("vColor1 %i",PlayerVehicle[i][vColor1]);
            printf("vColor2 %i",PlayerVehicle[i][vColor2]);
            printf("vHealth %f",PlayerVehicle[i][vHealth]);
            printf("vModel %i",PlayerVehicle[i][vModel]);
            printf("vPrio '%s'",PlayerVehicle[i][vPrio]);
            printf("vTake %i",PlayerVehicle[i][vTake]);*/
            //print("\nVehicle loaded");
        
}
    }
    
printf("Vehicle loaded\nMax ID : %i"GetVehiclePoolSize());