SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 11/07/2015, 10:31 AM   #1
Emmet_
Guest
 
Posts: n/a
Default OnVehicleModEx

OnVehicleModEx

Just a simple include which provides more control over the San Andreas tuning garages. For example, if your script has money cheating protection then you can just deduct the price of the component from the money variable in the script.

pawn Code:
public OnVehicleModEx(playerid, vehicleid, componentid, price, illegal);

Functions:

pawn Code:
native IsPlayerInModShop(playerid);
native IsValidComponentForVehicle(vehicleid, componentid);
native GetVehicleComponentPrice(componentid);
native GetComponentName(componentid, name[], len = sizeof(name));

There are also two constants: MIN_COMPONENT_ID and MAX_COMPONENT_ID. Each of these values represent the minimum valid component ID, and the maximum valid component ID, respectively.

pawn Code:
print("The Sultan has the following valid components:");

for (new i = MIN_COMPONENT_ID; i <= MAX_COMPONENT_ID; i ++)
{
    if (IsValidComponentForVehicle(gSultan, i))
    {
        printf("- %i", i);
    }
}

It also has protection over invalid modifications to prevent players from crashing. Also, any attempt to modify a vehicle outside a tuning garage or as a passenger will discard the modification, and "illegal" will be set to true.

Credits to JernejL for the list of legal mods which can be found here.

Download: https://www.dropbox.com/s/lf3u8c9j84...ModEx.inc?dl=1

Last edited by Emmet_; 15/08/2015 at 12:06 PM.
  Reply With Quote
Old 11/07/2015, 10:49 AM   #2
PT
Godfather
 
PT's Avatar
 
Join Date: Nov 2012
Location: Europe
Posts: 7,180
Reputation: 803
Default Re: OnVehicleModEx

I really like what you did here.

Keep the good work!
PT is offline   Reply With Quote
Old 11/07/2015, 10:51 AM   #3
Gasman
Little Clucker
 
Gasman's Avatar
 
Join Date: May 2015
Location: VietNam
Posts: 33
Reputation: 73
Default Re: OnVehicleModEx

Very Useful...
+Rep
Gasman is offline   Reply With Quote
Old 11/07/2015, 11:06 AM   #4
kristo
Banned
 
Join Date: Jun 2012
Location: Estonia
Posts: 352
Reputation: 179
Default Re: OnVehicleModEx

The illegal mods array is a bit wrong. I collected all the updates from that thread last month and this is the result:

pawn Code:
{400, 1024,1021,1020,1019,1018,1013,0000,0000,0000,0000,0000,0000,0000,0000},
    {401, 1145,1144,1143,1142,1020,1019,1017,1013,1007,1006,1005,1004,1003,1001},
    {404, 1021,1020,1019,1017,1016,1013,1007,1002,1000,0000,0000,0000,0000,0000},
    {405, 1023,1021,1020,1019,1018,1014,1001,1000,0000,0000,0000,0000,0000,0000},
    {410, 1024,1023,1021,1020,1019,1017,1013,1007,1003,1001,0000,0000,0000,0000},
    {415, 1023,1019,1018,1017,1007,1003,1001,0000,0000,0000,0000,0000,0000,0000},
    {418, 1021,1020,1016,1006,1002,0000,0000,0000,0000,0000,0000,0000,0000,0000},
    {420, 1021,1019,1005,1004,1003,1001,0000,0000,0000,0000,0000,0000,0000,0000},
    {421, 1023,1021,1020,1019,1018,1016,1014,1000,0000,0000,0000,0000,0000,0000},
    {422, 1021,1020,1019,1017,1013,1007,0000,0000,0000,0000,0000,0000,0000,0000},
    {426, 1021,1019,1006,1005,1004,1003,1001,0000,0000,0000,0000,0000,0000,0000},
    {436, 1022,1021,1020,1019,1017,1013,1007,1006,1003,1001,0000,0000,0000,0000},
    {439, 1145,1144,1143,1142,1023,1017,1013,1007,1003,1001,0000,0000,0000,0000},
    {477, 1021,1020,1019,1018,1017,1007,1006,0000,0000,0000,0000,0000,0000,0000},
    {478, 1024,1022,1021,1020,1013,1012,1005,1004,0000,0000,0000,0000,0000,0000},
    {489, 1024,1020,1019,1018,1016,1013,1006,1005,1004,1002,1000,0000,0000,0000},
    {491, 1145,1144,1143,1142,1023,1021,1020,1019,1018,1017,1014,1007,1003,0000},
    {492, 1016,1006,1005,1004,1000,0000,0000,0000,0000,0000,0000,0000,0000,0000},
    {496, 1143,1142,1023,1020,1019,1017,1011,1007,1006,1003,1002,1001,0000,0000},
    {500, 1024,1021,1020,1019,1013,0000,0000,0000,0000,0000,0000,0000,0000,0000},
    {516, 1021,1020,1019,1018,1017,1016,1015,1007,1004,1002,1000,0000,0000,0000},
    {517, 1145,1144,1143,1142,1023,1020,1019,1018,1017,1016,1007,1003,1002,0000},
    {518, 1145,1144,1143,1142,1023,1020,1018,1017,1013,1007,1006,1005,1003,1001},
    {527, 1021,1020,1018,1017,1015,1014,1007,1001,0000,0000,0000,0000,0000,0000},
    {529, 1023,1020,1019,1018,1017,1012,1011,1007,1006,1003,1001,0000,0000,0000},
    {534, 1185,1180,1179,1178,1127,1126,1125,1124,1123,1122,1106,1101,1100,0000},
    {535, 1121,1120,1119,1118,1117,1116,1115,1114,1113,1110,1109,0000,0000,0000},
    {536, 1184,1183,1182,1181,1128,1108,1107,1105,1104,1103,0000,0000,0000,0000},
    {540, 1145,1144,1143,1142,1024,1023,1020,1019,1018,1017,1007,1006,1004,1001},
    {542, 1145,1144,1021,1020,1019,1018,1015,1014,0000,0000,0000,0000,0000,0000},
    {546, 1145,1144,1143,1142,1024,1023,1019,1018,1017,1007,1006,1004,1002,1001},
    {547, 1143,1142,1021,1020,1019,1018,1016,1003,1000,0000,0000,0000,0000,0000},
    {549, 1145,1144,1143,1142,1023,1020,1019,1018,1017,1012,1011,1007,1003,1001},
    {550, 1145,1144,1143,1142,1023,1020,1019,1018,1006,1005,1004,1003,1001,0000},
    {551, 1023,1021,1020,1019,1018,1016,1006,1005,1003,1002,0000,0000,0000,0000},
    {558, 1168,1167,1166,1165,1164,1163,1095,1094,1093,1092,1091,1090,1089,1088},
    {559, 1173,1162,1161,1160,1159,1158,1072,1071,1070,1069,1068,1067,1066,1065},
    {560, 1170,1169,1141,1140,1139,1138,1033,1032,1031,1030,1029,1028,1027,1026},
    {561, 1157,1156,1155,1154,1064,1063,1062,1061,1060,1059,1058,1057,1056,1055},
    {562, 1172,1171,1149,1148,1147,1146,1041,1040,1039,1038,1037,1036,1035,1034},
    {565, 1153,1152,1151,1150,1054,1053,1052,1051,1050,1049,1048,1047,1046,1045},
    {567, 1189,1188,1187,1186,1133,1132,1131,1130,1129,1102,0000,0000,0000,0000},
    {575, 1177,1176,1175,1174,1099,1044,1043,1042,0000,0000,0000,0000,0000,0000},
    {576, 1193,1192,1191,1190,1137,1136,1135,1134,0000,0000,0000,0000,0000,0000},
    {580, 1023,1020,1018,1017,1007,1006,1001,0000,0000,0000,0000,0000,0000,0000},
        {585, 1145,1144,1143,1142,1020,1019,1018,1013,1006,1001,1023,1003,1007,1017},
    {589, 1145,1144,1024,1020,1018,1017,1016,1013,1007,1006,1005,1004,1000,0000},
    {600, 1022,1020,1018,1017,1013,1007,1006,1005,1004,0000,0000,0000,0000,0000},
    {603, 1145,1144,1143,1142,1024,1023,1020,1019,1018,1017,1007,1006,1001,0000}

Edit: I like the fact that you're releasing a lot of useful includes again. Good job!

Edit2: I think you should hook OnPlayerConnect in case someone logs out or crashes in a mod shop.

Edit3: So many edits, lol. The loops could be optimised as well.
kristo is offline   Reply With Quote
Old 11/07/2015, 11:14 AM   #5
Emmet_
Guest
 
Posts: n/a
Default Re: OnVehicleModEx

That's because I filled in the missing model ID's so that way I can access the index of the array using model ID, instead of using loop.
  Reply With Quote
Old 11/07/2015, 11:26 AM   #6
kristo
Banned
 
Join Date: Jun 2012
Location: Estonia
Posts: 352
Reputation: 179
Default Re: OnVehicleModEx

Actually there are only two edits:

pawn Code:
{561, 1157,1156,1155,1154,1064,1063,1062,1061,1060,1059,1058,1057,1056,1055},

{585, 1145,1144,1143,1142,1020,1019,1018,1013,1006,1001,1023,1003,1007,1017},

You can make the array smaller now, ID561 had some wrongly assigned component IDs there.
kristo is offline   Reply With Quote
Old 07/08/2015, 10:56 AM   #7
Emmet_
Guest
 
Posts: n/a
Default Re: OnVehicleModEx

A minor update.

Code:
- The "s_bModShopStatus" variable is now reset upon player connection.

- The component sets for the Stratum and Emperor contained wrongly assigned IDs (thanks to kvann for reporting).

- Renamed "IsModificationSupported" to "IsValidComponentForVehicle", which is a more logical name.

- Added GetComponentName and IsPlayerInModShop.
  Reply With Quote
Old 15/08/2015, 11:36 AM   #8
dominik523
Gangsta
 
dominik523's Avatar
 
Join Date: Feb 2013
Location: Croatia
Posts: 843
Reputation: 115
Default Re: OnVehicleModEx

Awesome job Emmet!
I'm so glad to see price parameter. It will work so nice with any scrited money system.
__________________
[Tutorial] Using new SHA-256 function
dominik523 is offline   Reply With Quote
Old 15/08/2015, 11:47 AM   #9
Kyle
High-roller
 
Join Date: Mar 2009
Location: United Kingdom
Posts: 2,260
Reputation: 333
Default Re: OnVehicleModEx

Why not convert the array to bits?
Kyle is offline   Reply With Quote
Old 15/08/2015, 02:03 PM   #10
Dutheil
Gangsta
 
Dutheil's Avatar
 
Join Date: Jul 2014
Location: France
Posts: 507
Reputation: 221
Default Re : OnVehicleModEx

Thanks Emmet !
__________________
#PrayForFrenchForum
GitHub

pawn Code:
print({1466458484, 543452960, 2037347616, 1952999790, 1797286260, 544694643, 543649646, 1851859053, 1634428192, 1056964608});
Dutheil is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 10:12 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.