SA-MP Forums Archive
Get Vehicle Color - 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: Get Vehicle Color (/showthread.php?tid=634447)



Get Vehicle Color - Antenastyle - 19.05.2017

Anyone here knows how to detect the color of a vehicle?

I tried this, but didn't work.
https://sampforum.blast.hk/showthread.php?tid=235398


Re: Get Vehicle Color - aoky - 19.05.2017

Can you show us some code please.


Re: Get Vehicle Color - Antenastyle - 19.05.2017

Quote:
Originally Posted by aoky
Посмотреть сообщение
Can you show us some code please.
What code do you want me to show? xD


Re: Get Vehicle Color - aoky - 19.05.2017

You said you tried but it didn't work, can you show us what you tried?


Re: Get Vehicle Color - Antenastyle - 19.05.2017

Quote:
Originally Posted by aoky
Посмотреть сообщение
You said you tried but it didn't work, can you show us what you tried?
That
Quote:
Originally Posted by Antenastyle
Посмотреть сообщение



Re: Get Vehicle Color - aoky - 19.05.2017

Quote:
Originally Posted by Antenastyle
Посмотреть сообщение
That
How do we know he's done it correctly, without him providing code there is nothing we can attempt to help him with.


Re: Get Vehicle Color - Antenastyle - 19.05.2017

Quote:
Originally Posted by aoky
Посмотреть сообщение
How do we know he's done it correctly, without him providing code there is nothing we can attempt to help him with.
Can you see that forum?? Anyways, I post here the code, but I don't use it because it doesn't work...

Код:
#if defined _Included_GetVehicleColor
        #endinput
#endif
 
#define _Included_GetVehicleColor
 
#define PROPERTY_OFFSET(%0) \
        ((((%0) * ((%0) << 1)) << 2) + 65536)
 
stock n_AddStaticVehicle(modelID, Float: spawn_X, Float: spawn_Y, Float: spawn_Z, Float: z_Angle, color1, color2)
{
        if(color1 < 0 || color2 < 0)
        {
                color1 = random(127);
                color2 = random(127);
        }
        modelID = AddStaticVehicle(modelID, spawn_X, spawn_Y, spawn_Z, z_Angle, color1, color2);
       
        new
                colorStr[24]
        ;      
        format(colorStr, sizeof(colorStr), "%d-%d", color1, color2);
        setproperty(_, "", PROPERTY_OFFSET(modelID), colorStr);
       
        return modelID;
}
 
stock n_AddStaticVehicleEx(modelID, Float: spawn_X, Float: spawn_Y, Float: spawn_Z, Float: z_Angle, color1, color2, respawn_Delay)
{
        if(color1 < 0 || color2 < 0)
        {
                color1 = random(127);
                color2 = random(127);
        }
        modelID = AddStaticVehicleEx(modelID, spawn_X, spawn_Y, spawn_Z, z_Angle, color1, color2, respawn_Delay);
       
        new
                colorStr[24]
        ;      
        format(colorStr, sizeof(colorStr), "%d-%d", color1, color2);
        setproperty(_, "", PROPERTY_OFFSET(modelID), colorStr);
       
        return modelID;
}
 
stock n_CreateVehicle(modelID, Float: spawn_X, Float: spawn_Y, Float: spawn_Z, Float: z_Angle, color1, color2, respawn_Delay)
{
        if(color1 < 0 || color2 < 0)
        {
                color1 = random(127);
                color2 = random(127);
        }
        modelID = CreateVehicle(modelID, spawn_X, spawn_Y, spawn_Z, z_Angle, color1, color2, respawn_Delay);
       
        new
                colorStr[24]
        ;      
        format(colorStr, sizeof(colorStr), "%d-%d", color1, color2);
        setproperty(_, "", PROPERTY_OFFSET(modelID), colorStr);
       
        return modelID;
}
 
stock n_DestroyVehicle(vehicleID)
{
        deleteproperty(_, "", PROPERTY_OFFSET(vehicleID));
       
        return DestroyVehicle(vehicleID);
}
 
stock n_ChangeVehicleColor(vehicleID, color1, color2)
{
        new
                colorStr[24]
        ;      
        format(colorStr, sizeof(colorStr), "%d-%d", color1, color2);
        setproperty(_, "", PROPERTY_OFFSET(vehicleID), colorStr);
       
        return ChangeVehicleColor(vehicleID, color1, color2);
}
 
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
        new
                colorStr[24]
        ;      
        format(colorStr, sizeof(colorStr), "%d-%d", color1, color2);
        setproperty(_, "", PROPERTY_OFFSET(vehicleid), colorStr);
       
        if(funcidx("n_OnVehicleRespray") != -1)
        {
                return CallLocalFunction("n_OnVehicleRespray", "iiii", playerid, vehicleid, color1, color2);
        }
        return 1;
}
 
stock GetVehicleColor(vehicleID, &color1, &color2)
{
        vehicleID = PROPERTY_OFFSET(vehicleID);
       
        if(existproperty(_, "", vehicleID))
        {
                new
                        colorStr[24],
                        strPos
                ;
                getproperty(_, "", vehicleID, colorStr);
                strunpack(colorStr, colorStr);
               
                if((strPos = strfind(colorStr, "-")) != -1)
                {
                        color1 = strval(colorStr);
                        color2 = strval(colorStr[strPos + 1]);
                        return 1;
                }
        }
        return 0;
}
 
#define AddStaticVehicle n_AddStaticVehicle
#define AddStaticVehicleEx n_AddStaticVehicleEx
#define CreateVehicle n_CreateVehicle
#define DestroyVehicle n_DestroyVehicle
#define ChangeVehicleColor n_ChangeVehicleColor
 
#if defined _ALS_OnVehicleRespray
        #undef OnVehicleRespray
#else
        #define _ALS_OnVehicleRespray
#endif
 
#define OnVehicleRespray n_OnVehicleRespray
 
forward n_OnVehicleRespray(playerid, vehicleid, color1, color2);



Re: Get Vehicle Color - rolex - 19.05.2017

You've set #include <GetVehicleColor> on top of your gamemode?


Re: Get Vehicle Color - aoky - 19.05.2017

Put your defines at the top of the script please.


Re: Get Vehicle Color - Aly - 19.05.2017

Can you show us the error you're getting?