SA-MP Forums Archive
Using ReturnVehicleModelID(id); - 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: Using ReturnVehicleModelID(id); (/showthread.php?tid=448413)



Using ReturnVehicleModelID(id); - Black Axe - 04.07.2013

Well , Basically - I was wondering how to add that function to my command.

Instead of using ID's - I'd like to use names too.

Here is the CMD :

PHP код:
    if(PlayerInfo[playerid][pAdmin] < 1337) return SCM(playerid, "You cannot use this command.");
    new 
model, color1, color2, faction, family, vip, Float:x, Float:y, Float:z, Float:a, string[512];
    new 
id, DBResult:dbResult[2], attempts, bool:found;
    
GetPlayerPos(playerid, x, y, z); GetPlayerFacingAngle(playerid, a);
    if(
sscanf(params, "dddddd", model, color1, color2, faction, family, vip)) return SyntaxMessage(playerid, "/permcar [model] [color 1] [color 2] [faction] [family] [VIP]");
    if(
model < 400 || model > 611) return SCM(playerid, "Invalid model ID/Name.");
    if(
color1 < 0 || color1 > 255) return SCM(playerid, "Invalid color ID.");
    if(
color2 < 0 || color2 > 255) return SCM(playerid, "Invalid color ID."); 
Notice : That's not the full CMD - But it's the needed part.
Thank you.


Re: Using ReturnVehicleModelID(id); - Misiur - 04.07.2013

Take a look at ReturnVehicleModelID code. It takes in a string, and returns id. So:
pawn Код:
//find
new model, color1, color2, faction, family, vip, Float:x, Float:y, Float:z, Float:a, string[512];
//change to
new model, color1, color2, faction, family, vip, Float:x, Float:y, Float:z, Float:a, string[512], modelstr[64+1];

//find
if(sscanf(params, "dddddd", model, color1, color2, faction, family, vip)) return SyntaxMessage(playerid, "/permcar [model] [color 1] [color 2] [faction] [family] [VIP]");
//change to
if(sscanf(params, "s[64]ddddd", modelstr, color1, color2, faction, family, vip)) return SyntaxMessage(playerid, "/permcar [model] [color 1] [color 2] [faction] [family] [VIP]");
model = ReturnVehicleModelID(modelstr);