Welcome, Guest |
You have to register before you can post on our site.
|
Online Users |
There are currently 231 online users. » 1 Member(s) | 228 Guest(s) Google, Bing, shiftdapentas
|
Latest Threads |
Plan C: Protect The Presi...
Forum: Advertisements
Last Post: PipPo
10 hours ago
» Replies: 0
» Views: 18
|
CODE5 GAMING COPS AND ROB...
Forum: Advertisements
Last Post: ryanthiago789
Yesterday, 03:02 AM
» Replies: 0
» Views: 30
|
SAMP RP project in 2024? ...
Forum: General Discussions
Last Post: tommchris
Yesterday, 02:05 AM
» Replies: 4
» Views: 2,463
|
Infekcja 2: Zombie Surviv...
Forum: Serwery
Last Post: tunnelrushgame3d
Yesterday, 01:50 AM
» Replies: 1
» Views: 191
|
FPS issues
Forum: General Discussions
Last Post: kourtneyroberts
2025-04-28, 04:53 AM
» Replies: 0
» Views: 23
|
How to make your GTA SA:M...
Forum: Tutorials
Last Post: NoxxeR
2025-04-27, 11:26 AM
» Replies: 1
» Views: 81
|
Problem about pawnbot
Forum: Pawn Scripting
Last Post: balkanspeed18
2025-04-26, 02:04 PM
» Replies: 0
» Views: 39
|
Error
Forum: Pawn Scripting
Last Post: -N0FeaR-
2025-04-25, 12:05 PM
» Replies: 0
» Views: 41
|
GTA Multigames [ MultiMod...
Forum: Advertisements
Last Post: Undead
2025-04-25, 07:37 AM
» Replies: 0
» Views: 52
|
Atlanta DeathMatch
Forum: Advertisements
Last Post: NixaSha
2025-04-25, 01:19 AM
» Replies: 0
» Views: 45
|
|
|
[Help] Dealership disappears after server restart |
Posted by: Disretired - 2021-01-22, 07:24 AM - Forum: Pawn Scripting
- Replies (5)
|
 |
Hello again, myself and my friends could use a hand on this issue as we haven't been able to fix it regardless of what we try.
So our vehicle dealerships disappears after server restart, I've checked the ini file it is writing the info for the lots too and it does show the dealership we created in it, however when we go in game after a restart it does not load that dealership in, we've been trying to fix this for about two or three weeks now with know solution in site, I kindly ask that if anyone knows how to fix this so that it will properly load after restart to please help us out.
Below I've attached every line i see mentioning the dealership.
Code: #define DIALOG_GPS_LA_CARDEALERSHIPS 32637
//=========================================================================//
#define MAX_DEALERSHIPVEHICLES 51
#define MAX_CARDEALERSHIPS 51
//=========================================================================//
enum cdInfo
{
cdOwned,
cdOwner[MAX_PLAYER_NAME],
Float: cdEntranceX,
Float: cdEntranceY,
Float: cdEntranceZ,
Float: cdExitX,
Float: cdExitY,
Float: cdExitZ,
cdMessage[128],
cdTill,
cdInterior,
Float: cdRadius,
cdPrice,
cdPickupID,
Text3D:cdTextLabel,
Text3D:cdVehicleLabel[MAX_DEALERSHIPVEHICLES],
cdVehicleModel[MAX_DEALERSHIPVEHICLES],
cdVehicleCost[MAX_DEALERSHIPVEHICLES],
cdVehicleId[MAX_DEALERSHIPVEHICLES],
Float: cdVehicleSpawnX[MAX_DEALERSHIPVEHICLES],
Float: cdVehicleSpawnY[MAX_DEALERSHIPVEHICLES],
Float: cdVehicleSpawnZ[MAX_DEALERSHIPVEHICLES],
Float: cdVehicleSpawnAngle[MAX_DEALERSHIPVEHICLES],
Float: cdVehicleSpawn[4],
};
new CarDealershipInfo[MAX_CARDEALERSHIPS][cdInfo];
//=========================================================================//
}
? ? if(GetCarDealershipVehicleId(newcar) != -1 && GetCarDealershipVehicleId(newcar) == GetPVarInt(playerid, "editingcdveh")) return 1;
? ? ? ? if(GetCarDealershipVehicleId(newcar) != -1)
? ? ? ? {
new string[57 20 4];
format(string, sizeof(string),"Would you like to buy this %s?\n\nThis vehicle costs $%d.", GetVehicleName(newcar), CarDealershipInfo[GetCarDealershipId(newcar)][cdVehicleCost][GetCarDealershipVehicleId(newcar)]);
? ? ShowPlayerDialog(playerid,DIALOG_CDBUY,DIALOG_STYLE_MSGBOX,"LB-Gaming CAR DEALERSHIP",string,"Buy","Cancel");
? ? TogglePlayerControllable(playerid, false);
? ? return 1;
? ? ? ? }
GetVehicleParamsEx(newcar,engine,lights,alarm,doors,bonnet,boot,objective);
if((engine == VEHICLE_PARAMS_UNSET || engine == VEHICLE_PARAMS_OFF) && GetVehicleModel(newcar) != 509 && GetVehicleModel(newcar) != 481 && GetVehicleModel(newcar) != 510) {
SendClientMessageEx(playerid, COLOR_WHITE, "This vehicle's engine is not running - if you wish to start it, type /car engine.");
}
else
{
if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 481 && GetVehicleModel(GetPlayerVehicleID(playerid)) != 509 && GetVehicleModel(GetPlayerVehicleID(playerid)) != 510)
{
//format(erpstring, sizeof(erpstring), "%.2f GAL", VehicleFuel[GetPlayerVehicleID(playerid)]);
//TextDrawSetString(FuelText[playerid],erpstring);
}
}
}
//=========================================================================//
LoadcDealerships()
{
? ? new string2[64];
format(string2, sizeof(string2), "cardealerships.ini");
new File: DealerFile = fopen(string2, io_read);
if ( DealerFile )
{
new key[ 256 ] , val[ 256 ];
new Data[ 256 ];
while ( fread( DealerFile , Data , sizeof( Data ) ) )
{
? ? new string[128];
? ? for(new f = 0; f < MAX_FAMILY; f)
? ? {
key = ini_GetKey( Data );
format(string, 128, "cd%dOwned",f);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdOwned] = strval( val ); }
format(string, 128, "cd%dOwner",f);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); strmid(CarDealershipInfo[f][cdOwner], val, 0, strlen(val)-1, 255); }
format(string, 128, "cd%dEntranceX",f);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdEntranceX] = floatstr( val ); }
format(string, 128, "cd%dEntranceY",f);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdEntranceY] = floatstr( val ); }
format(string, 128, "cd%dEntranceZ",f);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdEntranceZ] = floatstr( val ); }
format(string, 128, "cd%dExitX",f);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdExitX] = floatstr( val ); }
format(string, 128, "cd%dExitY",f);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdExitY] = floatstr( val ); }
format(string, 128, "cd%dExitZ",f);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdExitZ] = floatstr( val ); }
format(string, 128, "cd%dMessage",f);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); strmid(CarDealershipInfo[f][cdMessage], val, 0, strlen(val)-1, 255); }
format(string, 128, "cd%dTill",f);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdTill] = strval( val ); }
format(string, 128, "cd%dInterior",f);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdInterior] = strval( val ); }
format(string, 128, "cd%dVehicleSpawn0",f);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdVehicleSpawn][0] = floatstr( val ); }
format(string, 128, "cd%dVehicleSpawn1",f);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdVehicleSpawn][1] = floatstr( val ); }
format(string, 128, "cd%dVehicleSpawn2",f);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdVehicleSpawn][2] = floatstr( val ); }
format(string, 128, "cd%dVehicleSpawn3",f);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdVehicleSpawn][3] = floatstr( val ); }
format(string, 128, "cd%dRadius",f);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdRadius] = floatstr( val ); }
format(string, 128, "cd%dPrice",f);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdPrice] = strval( val ); }
for(new fv = 0; fv < MAX_DEALERSHIPVEHICLES; fv)
? ? {
? ? ? ? format(string, 128, "cd%dVeh%dModelId",f, fv);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdVehicleModel][fv] = strval( val ); }
format(string, 128, "cd%dVeh%dCost",f, fv);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdVehicleCost][fv] = strval( val ); }
format(string, 128, "cd%dVeh%dSpawnX",f, fv);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdVehicleSpawnX][fv] = floatstr( val ); }
format(string, 128, "cd%dVeh%dSpawnY",f, fv);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdVehicleSpawnY][fv] = floatstr( val ); }
format(string, 128, "cd%dVeh%dSpawnZ",f, fv);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdVehicleSpawnZ][fv] = floatstr( val ); }
format(string, 128, "cd%dVeh%dSpawnA",f, fv);
if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); CarDealershipInfo[f][cdVehicleSpawnAngle][fv] = floatstr( val ); }
? ? }
}
}
fclose(DealerFile);
}
return 1;
}
SavecDealerships()
{
new string3[32];
format(string3, sizeof(string3), "cardealerships.ini");
new File: hFile = fopen(string3, io_write);
if (hFile)
{
new var[32];
for(new f = 0; f < MAX_CARDEALERSHIPS; f)
? {
format(var, 32, "cd%dOwned=%d\n",f, CarDealershipInfo[f][cdOwned]); fwrite(hFile, var);
format(var, 32, "cd%dOwner=%s\n",f, CarDealershipInfo[f][cdOwner]); fwrite(hFile, var);
format(var, 32, "cd%dEntranceX=%.1f\n",f, CarDealershipInfo[f][cdEntranceX]); fwrite(hFile, var);
format(var, 32, "cd%dEntranceY=%.1f\n",f, CarDealershipInfo[f][cdEntranceY]); fwrite(hFile, var);
format(var, 32, "cd%dEntranceZ=%.1f\n",f, CarDealershipInfo[f][cdEntranceZ]); fwrite(hFile, var);
format(var, 32, "cd%dExitX=%.1f\n",f, CarDealershipInfo[f][cdExitX]); fwrite(hFile, var);
format(var, 32, "cd%dExitY=%.1f\n",f, CarDealershipInfo[f][cdExitX]); fwrite(hFile, var);
format(var, 32, "cd%dExitZ=%.1f\n",f, CarDealershipInfo[f][cdExitX]); fwrite(hFile, var);
format(var, 32, "cd%dMessage=%s\n\n",f, CarDealershipInfo[f][cdMessage]); fwrite(hFile, var);
format(var, 32, "cd%dTill=%d\n",f, CarDealershipInfo[f][cdTill]); fwrite(hFile, var);
format(var, 32, "cd%dInterior=%d\n",f, CarDealershipInfo[f][cdInterior]); fwrite(hFile, var);
format(var, 32, "cd%dVehicleSpawn0=%.1f\n",f, CarDealershipInfo[f][cdVehicleSpawn][0]); fwrite(hFile, var);
format(var, 32, "cd%dVehicleSpawn1=%.1f\n",f, CarDealershipInfo[f][cdVehicleSpawn][1]); fwrite(hFile, var);
format(var, 32, "cd%dVehicleSpawn2=%.1f\n",f, CarDealershipInfo[f][cdVehicleSpawn][2]); fwrite(hFile, var);
format(var, 32, "cd%dVehicleSpawn3=%.1f\n",f, CarDealershipInfo[f][cdVehicleSpawn][3]); fwrite(hFile, var);
format(var, 32, "cd%dRadius=%.1f\n",f, CarDealershipInfo[f][cdRadius]); fwrite(hFile, var);
format(var, 32, "cd%dPrice=%d\n",f, CarDealershipInfo[f][cdPrice]); fwrite(hFile, var);
for(new fv = 0; fv < MAX_DEALERSHIPVEHICLES; fv)
? {
? ? ? format(var, 32, "cd%dVeh%dModelId=%d\n",f, fv, CarDealershipInfo[f][cdVehicleModel][fv]); fwrite(hFile, var);
format(var, 32, "cd%dVeh%dCost=%d\n",f, fv,CarDealershipInfo[f][cdVehicleCost][fv]); fwrite(hFile, var);
format(var, 32, "cd%dVeh%dSpawnX=%.1f\n",f, fv,CarDealershipInfo[f][cdVehicleSpawnX][fv]); fwrite(hFile, var);
format(var, 32, "cd%dVeh%dSpawnY=%.1f\n",f, fv,CarDealershipInfo[f][cdVehicleSpawnY][fv]); fwrite(hFile, var);
format(var, 32, "cd%dVeh%dSpawnZ=%.1f\n",f, fv,CarDealershipInfo[f][cdVehicleSpawnZ][fv]); fwrite(hFile, var);
format(var, 32, "cd%dVeh%dSpawnA=%.1f\n",f, fv,CarDealershipInfo[f][cdVehicleSpawnAngle][fv]); fwrite(hFile, var);
? ? }
? }
fclose(hFile);
}
return 1;
}
//=========================================================================//
LoadcDealerships();
//=========================================================================//
}
new text_info[128];
for(new d = 0; d < sizeof(CarDealershipInfo); d)
{
if(CarDealershipInfo[d][cdEntranceX] != 0.0 && CarDealershipInfo[d][cdEntranceY] != 0.0)
{
CarDealershipInfo[d][cdPickupID] = CreateDynamicPickup(1239, 1, CarDealershipInfo[d][cdEntranceX], CarDealershipInfo[d][cdEntranceY], CarDealershipInfo[d][cdEntranceZ]);
if(CarDealershipInfo[d][cdOwned])
{
? ? ? ? ? ? format(text_info, sizeof(text_info),"Car Dealership %s\nOwner: %s\nRadius: %.1f\nID: %d", CarDealershipInfo[d][cdMessage], CarDealershipInfo[d][cdOwner], CarDealershipInfo[d][cdRadius], d);
? ? ? ? ? ? CarDealershipInfo[d][cdTextLabel] = CreateDynamic3DTextLabel(text_info,COLOR_GREEN,CarDealershipInfo[d][cdEntranceX], CarDealershipInfo[d][cdEntranceY], CarDealershipInfo[d][cdEntranceZ].75,3.0,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,1);
}
else
{
? ? ? ? ? ? format(text_info, sizeof(text_info),"Car Dealership %s For Sale\nPrice: %d\nRadius: %.1f\nID: %d", CarDealershipInfo[d][cdMessage], CarDealershipInfo[d][cdPrice], CarDealershipInfo[d][cdRadius], d);
? ? ? ? ? ? CarDealershipInfo[d][cdTextLabel] = CreateDynamic3DTextLabel(text_info,COLOR_RED,CarDealershipInfo[d][cdEntranceX], CarDealershipInfo[d][cdEntranceY], CarDealershipInfo[d][cdEntranceZ].75,3.0,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,1);
}
}
for(new v = 0; v < MAX_DEALERSHIPVEHICLES; v)
? ? {
if (CarDealershipInfo[d][cdVehicleModel][v] != 0)
{
? ? ? ? new carcreated = CreateVehicleEx(CarDealershipInfo[d][cdVehicleModel][v], CarDealershipInfo[d][cdVehicleSpawnX][v], CarDealershipInfo[d][cdVehicleSpawnY][v], CarDealershipInfo[d][cdVehicleSpawnZ][v], CarDealershipInfo[d][cdVehicleSpawnAngle][v], 0, 0, 6);
? ? ? ? format(text_info, sizeof(text_info), "%s For Sale\nPrice: %d", GetVehicleName(carcreated), CarDealershipInfo[d][cdVehicleCost][v]);
? ? ? ? ? ? ? ? CarDealershipInfo[d][cdVehicleLabel][v] = CreateDynamic3DTextLabel(text_info,COLOR_LIGHTBLUE,0.0, 0.0, 0.0,8.0,INVALID_PLAYER_ID,carcreated);
? ? ? ? ? ? ? ? CarDealershipInfo[d][cdVehicleId][v] = carcreated;
}
}
}
//=========================================================================//
CMD:editcardealership(playerid, params[])
{
? ? for(new d = 0 ; d < MAX_CARDEALERSHIPS; d)
{
? ? ? ? if(IsPlayerInRangeOfPoint(playerid, CarDealershipInfo[d][cdRadius], CarDealershipInfo[d][cdEntranceX], CarDealershipInfo[d][cdEntranceY], CarDealershipInfo[d][cdEntranceZ])) {
? ? ? ? ? ? if(PlayerInfo[playerid][pAdmin] >= 1337)
{
? ? ? ? ? ? ? ? SetPVarInt(playerid, "editingcd", d);
? ? ? ? ? ? ? ? SetPVarInt(playerid, "editingcdveh", -1);
? ? ? ? ? ? ? ? SetPVarInt(playerid, "editingcdvehpos", 0);
? ? ? ? ? ? ? ? SetPVarInt(playerid, "editingcdvehnew", 0);
? ? ? ? ? ? ? ? new listitems[] = "1 New Vehicle\n2 My Vehicles\n3 Upgrade\n4 Till";
? ? ? ? ? ? ? ? ShowPlayerDialog(playerid,DIALOG_CDEDIT,DIALOG_STYLE_LIST,"Car Dealership Editor:", listitems,"Select","Cancel");
? ? ? ? ? ? ? ? return 1;
? ? ? ? ? ? }
? ? ? ? ? ? else
{
? ? ? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, "You do not own that Car Dealership.");
? ? ? ? ? ? ? ? return 1;
? ? ? ? ? ? }
? ? ? ? }
? ? }
? ? SendClientMessageEx(playerid, COLOR_GREY, "ERROR: You must be standing inside the radius of the Car Dealership.");
? ? return 1;
}
CMD:editcar(playerid, params[])
{
? ? new vehicleid = GetPlayerVehicleID(playerid);
? ? new v, d;
? ? v = GetCarDealershipVehicleId(vehicleid);
? ? d = GetCarDealershipId(vehicleid);
? ? if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessageEx(playerid, COLOR_GREY, "ERROR: You are not in any car.");
? ? if(v != -1 && d != -1)
{
? ? ? ? if(PlayerInfo[playerid][pAdmin] >= 1337)
{
? ? ? ? ? ? SetPVarInt(playerid, "editingcd", d);
? ? ? ? ? ? SetPVarInt(playerid, "editingcdveh", v);
? ? ? ? ? ? SetPVarInt(playerid, "editingcdvehpos", 0);
? ? ? ? ? ? SetPVarInt(playerid, "editingcdvehnew", 0);
? ? ? ? ? ? new listitems[] = "1 Edit Model\n2 Edit Cost\n3 Edit Park\n4 Delete Vehicle";
? ? ? ? ? ? ShowPlayerDialog(playerid,DIALOG_CDEDITONE,DIALOG_STYLE_LIST,"Car Dealership Editor:", listitems,"Select","Cancel");
? ? ? ? ? ? return 1;
? ? ? ? }
? ? ? ? else
{
? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, "ERROR: You do not own that Car Dealership.");
? ? ? ? }
? ? }
? ? else
{
? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, "ERROR: Car is not part of a Car Dealership.");
? ? }
? ? return 1;
}
CMD:buydealership(playerid, params[])
{
? ? for(new d = 0 ; d < MAX_CARDEALERSHIPS; d)
{
? ? ? ? if(IsPlayerInRangeOfPoint(playerid, 3.0, CarDealershipInfo[d][cdEntranceX], CarDealershipInfo[d][cdEntranceY], CarDealershipInfo[d][cdEntranceZ]))
{
? ? ? ? ? ? if(!CarDealershipInfo[d][cdOwned])
{
? ? ? ? ? ? ? ? if(GetPVarInt(playerid, "Cash") < CarDealershipInfo[d][cdPrice])
{
? ? ? ? ? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, " You do not have enough money to buy this Car Dealership.");
? ? ? ? ? ? ? ? ? ? return 1;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? SetPVarInt(playerid, "Cash", GetPVarInt(playerid, "Cash")-CarDealershipInfo[d][cdPrice]);
? ? ? ? ? ? ? ? SetPlayerOwnerOfCD(playerid, d);
? ? ? ? ? ? ? ? PlayerPlayMusic(playerid);
? ? ? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_WHITE, " Type /help to review the new car dealership help section.");
? ? ? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GRAD1, " Please set the position you want your brought cars to spawn.");
? ? ? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GRAD2, " Stand where you want to have your brought vehicles spawn.");
? ? ? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GRAD2, " Once ready press the fire button.");
? ? ? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_WHITE, " NOTE: If you don't set it your customers wont be able to buy any cars.");
? ? ? ? ? ? ? ? SetPVarInt(playerid, "editingcdvehpos", 2);
? ? ? ? ? ? ? ? SetPVarInt(playerid, "editingcd", d);
? ? ? ? ? ? ? ? return 1;
? ? ? ? ? ? }
? ? ? ? ? ? else
{
? ? ? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, "That car dealership is already owned and it's not for sale.");
? ? ? ? ? ? }
? ? ? ? }
? ? }
? ? return 1;
}
CMD:selldealership(playerid, params[])
{
new string[128];
? ? for(new d = 0 ; d < MAX_CARDEALERSHIPS; d)
{
? ? ? ? if(IsPlayerInRangeOfPoint(playerid, 3.0, CarDealershipInfo[d][cdEntranceX], CarDealershipInfo[d][cdEntranceY], CarDealershipInfo[d][cdEntranceZ]))
{
? ? ? ? ? ? if(PlayerInfo[playerid][pAdmin] >= 1337)
{
? ? ? ? ? ? ? ? SetPVarInt(playerid, "editingcd", d);
? ? ? ? ? ? ? ? format(string,128,"Are you sure you want to sell this Car Dealership for $%d?\n.", CarDealershipInfo[d][cdPrice] / 2);
? ? ? ? ? ? ? ? ShowPlayerDialog(playerid,DIALOG_CDSELL,DIALOG_STYLE_MSGBOX,"Warning:",string,"Sell","Cancel");
? ? ? ? ? ? ? ? return 1;
? ? ? ? ? ? }
? ? ? ? ? ? else
{
? ? ? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, "You are not the owner of this car dealership.");
? ? ? ? ? ? ? ? return 1;
? ? ? ? ? ? }
? ? ? ? }
? ? }
? ? SendClientMessageEx(playerid, COLOR_GREY, "You have to be near a car dealership.");
? ? return 1;
}
CMD:createcdveh(playerid, params[])
{
? ? if (PlayerInfo[playerid][pAdmin] < 1337)
{
? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, " You are not allowed to use this command.");
? ? ? ? return 1;
? ? }
? ? new string[128], price, dealershipid, modelid;
? ? if(sscanf(params, "ddd", price, dealershipid, modelid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /createcdveh [price] [dealership] [modelid]");
? ? new Float:X,Float:Y,Float:Z,Float:A;
? ? GetPlayerPos(playerid,X,Y,Z);
? ? GetPlayerFacingAngle(playerid, A);
? ? new cdvehicleid = CreateCarDealershipVehicle(dealershipid, modelid, X, Y, Z, A, price);
? ? if(cdvehicleid == -1)
{
? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, "ERROR: cdVehicles limit reached.");
? ? }
? ? else
{
? ? ? ? format(string, sizeof(string), " SYSTEM: Car dealership vehicle created (M-ID %d)(ID %d)", modelid, cdvehicleid);
? ? ? ? SendClientMessageEx(playerid, COLOR_GRAD1, string);
? ? }
? ? return 1;
}
CMD:destroycdveh(playerid, params[])
{
? ? if (PlayerInfo[playerid][pAdmin] < 1337)
{
? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, " You are not allowed to use this command.");
? ? ? ? return 1;
? ? }
? ? new string[128], vehid;
? ? if(sscanf(params, "d", vehid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /destroycdveh [vehicleid]");
? ? DestroyCarDealershipVehicle(GetCarDealershipId(vehid), GetCarDealershipVehicleId(vehid));
? ? SavecDealerships();
? ? format(string, sizeof(string), " SYSTEM: Car dealership vehicle destroyed (ID %d)", vehid);
? ? SendClientMessageEx(playerid, COLOR_GRAD1, string);
? ? return 1;
}
CMD:createdealership(playerid, params[])
{
? ? if (PlayerInfo[playerid][pAdmin] < 1337)
{
? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, " You are not allowed to use this command.");
? ? ? ? return 1;
? ? }
? ? new string[128], price, radius, message[64];
? ? if(sscanf(params, "dds[64]", price, radius, message)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /createdealership [price] [radius] [message]");
? ? new Float:X,Float:Y,Float:Z;
? ? GetPlayerPos(playerid,X,Y,Z);
? ? new dealershipid = CreateCarDealership(X, Y, Z, radius, price, message);
? ? if(dealershipid == -1)
{
? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, "ERROR: Car Dealerships limit reached.");
? ? }
? ? else
{
? ? ? ? format(string, sizeof(string), " SYSTEM: Car dealership created (ID %d)", dealershipid);
? ? ? ? SendClientMessageEx(playerid, COLOR_GRAD1, string);
? ? }
? ? return 1;
}
CMD:destroydealership(playerid, params[])
{
? ? if (PlayerInfo[playerid][pAdmin] < 1337)
{
? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, " You are not allowed to use this command.");
? ? ? ? return 1;
? ? }
? ? new string[128], dealershipid;
? ? if(sscanf(params, "d", dealershipid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /destroydealership [dealershipid]");
? ? for(new d = 0 ; d < MAX_CARDEALERSHIPS; d)
{
? ? ? ? if(IsPlayerInRangeOfPoint(playerid, 3.0, CarDealershipInfo[d][cdEntranceX], CarDealershipInfo[d][cdEntranceY], CarDealershipInfo[d][cdEntranceZ]))
{
? ? ? ? ? ? DestroyCarDealership(d);
? ? ? ? ? ? format(string, sizeof(string), " Car Dealership destroyed with ID %d.", d);
? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GRAD1, string);
? ? ? ? ? ? return 1;
? ? ? ? }
? ? }
? ? if(dealershipid > MAX_CARDEALERSHIPS) return 1;
? ? if(dealershipid < 0) return 1;
? ? DestroyCarDealership(dealershipid);
? ? format(string, sizeof(string), " Car Dealership destroyed with ID %d.", dealershipid);
? ? SendClientMessageEx(playerid, COLOR_GRAD1, string);
? ? return 1;
}
//=========================================================================//
else if(dialogid == DIALOG_CDEDIT)
{ // car dealership dialog
if(response && GetPVarInt(playerid, "editingcd") != -1)
{
? ? ? ? ? ? if(listitem == 0) // New Vehicle
{
format(string, sizeof(string),"Please type the model ID of the new vehicle.");
? ? ? ? ShowPlayerDialog(playerid,DIALOG_CDNEWVEH,DIALOG_STYLE_INPUT,"Warning:",string,"Ok","Cancel");
}
else if(listitem == 1) // My Vehicles
{
new vehicles;
? ? ? ? ? ? ? ? for(new i=0; i<MAX_DEALERSHIPVEHICLES; i)
? ? ? ? ? ? {
if(CarDealershipInfo[GetPVarInt(playerid, "editingcd")][cdVehicleModel][i] != 0)
{
vehicles;
? ? ? ? ? ? ? ? format(string, sizeof(string), "Vehicle %d| Name: %s | Price: %d.",i,GetVehicleName(CarDealershipInfo[GetPVarInt(playerid, "editingcd")][cdVehicleId][i]),CarDealershipInfo[GetPVarInt(playerid, "editingcd")][cdVehicleCost][i]);
? ? ? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_WHITE, string);
}
}
if(vehicles)
{
? ? ShowPlayerDialog(playerid, DIALOG_CDEDITCARS, DIALOG_STYLE_INPUT, "Car Dealership:", " Choose a vehicle to edit:", "Edit", "Back");
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD2, " This car dealership doesn't have any cars.");
}
}
else if(listitem == 2) // Upgrade
{
new listitems[] = "1 Vehicle Spawn\n2 Radius\n3 Dealership Name\n4 Price";
? ? ShowPlayerDialog(playerid,DIALOG_CDUPGRADE,DIALOG_STYLE_LIST,"Choose an item to continue.", listitems,"Select","Cancel");
}
else if(listitem == 3) // Till
{
new listitems[] = "1 Withdraw\n2 Deposit";
? ? ShowPlayerDialog(playerid,DIALOG_CDTILL,DIALOG_STYLE_LIST,"Choose an item to continue.", listitems,"Select","Cancel");
}
}
else
{
SavecDealerships();
? ? ? ? ? ? SetPVarInt(playerid, "editingcd", -1);
}
}
else if(dialogid == DIALOG_CDTILL)
{ // car dealership dialog
? ? if(response && GetPVarInt(playerid, "editingcd") != -1)
{
? ? ? ? ? ? if(listitem == 0) // Withdraw
{
format(string, sizeof(string), "You have $%d in your till account.\n\n\tHow much money to withdraw?", CarDealershipInfo[GetPVarInt(playerid, "editingcd")][cdTill]);
ShowPlayerDialog(playerid,DIALOG_CDWITHDRAW,DIALOG_STYLE_INPUT,"Withdraw", string,"Select","Cancel");
}
else if(listitem == 1) // Deposit
{
format(string, sizeof(string), "You have $%d in your till account.\n\n\tHow much money to deposit?", CarDealershipInfo[GetPVarInt(playerid, "editingcd")][cdTill]);
ShowPlayerDialog(playerid,DIALOG_CDDEPOSIT,DIALOG_STYLE_INPUT,"Deposit", string,"Select","Cancel");
}
}
else
{
? ? ? ? ? ? SavecDealerships();
? ? ? ? ? ? SetPVarInt(playerid, "editingcd", -1);
}
}
else if(dialogid == DIALOG_CDWITHDRAW)
{ // car dealership dialog
if(response && GetPVarInt(playerid, "editingcd") != -1)
{
? ? if (IsNumeric(inputtext))
? ? ? ? {
? ? ? ? ? ? new money = strval(inputtext);
? ? ? ? ? ? if(CarDealershipInfo[GetPVarInt(playerid, "editingcd")][cdTill] < money)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? format(string, sizeof(string), "You don't have that much in your till!\n\nYou have $%d in your till account.\n\n\tHow much money to withdraw?", CarDealershipInfo[GetPVarInt(playerid, "editingcd")][cdTill]);
? ? ShowPlayerDialog(playerid,DIALOG_CDWITHDRAW,DIALOG_STYLE_INPUT,"Withdraw", string,"Select","Cancel");
? ? ? ? ? ? ? ? ? ? return 1;
? ? ? ? ? ? }
? ? ? ? ? ? CarDealershipInfo[GetPVarInt(playerid, "editingcd")][cdTill] -= money;
? ? ? ? ? ? SetPVarInt(playerid, "Cash", GetPVarInt(playerid, "Cash")骉);
? ? ? ? ? ? format(string, sizeof(string), "You have successfully withdrawn $%d from your till, new balance: $%d", money, CarDealershipInfo[GetPVarInt(playerid, "editingcd")][cdTill]);
? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GRAD2, string);
? ? ? ? ? ? SavecDealerships();
? ? ? ? ? ? ? ? SetPVarInt(playerid, "editingcd", -1);
}
? ? ? ? }
else
{
? ? ? ? ? ? SavecDealerships();
? ? ? ? ? ? SetPVarInt(playerid, "editingcd", -1);
}
}
else if(dialogid == DIALOG_CDDEPOSIT)
{ // car dealership dialog
if(response && GetPVarInt(playerid, "editingcd") != -1)
{
? ? if (IsNumeric(inputtext))
? ? ? ? {
? ? ? ? ? ? new money = strval(inputtext);
? ? ? ? ? ? if(GetPVarInt(playerid, "Cash") < money)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? format(string, sizeof(string), "You don't have that much in your wallet!\n\nYou have $%d in your till account.\n\n\tHow much money to deposit?", CarDealershipInfo[GetPVarInt(playerid, "editingcd")][cdTill]);
? ? ShowPlayerDialog(playerid,DIALOG_CDDEPOSIT,DIALOG_STYLE_INPUT,"Deposit", string,"Select","Cancel");
? ? ? ? ? ? ? ? ? ? return 1;
? ? ? ? ? ? }
? ? ? ? ? ? CarDealershipInfo[GetPVarInt(playerid, "editingcd")][cdTill] = money;
? ? ? ? ? ? SetPVarInt(playerid, "Cash", GetPVarInt(playerid, "Cash")-money);
? ? ? ? ? ? format(string, sizeof(string), "You have successfully deposited $%d to your till, new balance: $%d", money, CarDealershipInfo[GetPVarInt(playerid, "editingcd")][cdTill]);
? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GRAD2, string);
? ? ? ? ? ? SavecDealerships();
? ? ? ? ? ? ? ? SetPVarInt(playerid, "editingcd", -1);
}
}
else
{
? ? ? ? ? ? SavecDealerships();
? ? ? ? ? ? SetPVarInt(playerid, "editingcd", -1);
}
}
else if(dialogid == DIALOG_CDUPGRADE)
{ // car dealership dialog
if(response && GetPVarInt(playerid, "editingcd") != -1)
{
? ? ? ? ? ? if(listitem == 0) // Vehicle Spawn
{
SendClientMessageEx(playerid, COLOR_GRAD2, " Please stand where you want to have your brought vehicles spawn.");
SendClientMessageEx(playerid, COLOR_GRAD2, " Once ready press the fire button.");
SetPVarInt(playerid, "editingcdvehpos", 2);
}
? ? ? ? ? ? if(listitem == 1) // Radius
{
ShowPlayerDialog(playerid, DIALOG_CDRADIUS, DIALOG_STYLE_INPUT, "Car Dealership:", " Choose the new radius:", "Edit", "Back");
}
else if(listitem == 2) // Dealership Name
{
ShowPlayerDialog(playerid, DIALOG_CDNAME, DIALOG_STYLE_INPUT, "Car Dealership:", " Choose the new name:", "Edit", "Back");
}
else if(listitem == 3) // Price
{
ShowPlayerDialog(playerid, DIALOG_CDPRICE, DIALOG_STYLE_INPUT, "Car Dealership:", " Choose the new price:", "Edit", "Back");
}
}
else
{
? ? ? ? ? ? SavecDealerships();
? ? ? ? ? ? SetPVarInt(playerid, "editingcd", -1);
}
}
else if(dialogid == DIALOG_CDRADIUS)
{ // car dealership dialog
if(response && GetPVarInt(playerid, "editingcd") != -1)
{
new d;
d = GetPVarInt(playerid, "editingcd");
new Float:radius = floatstr(inputtext);
new Float:radiusex = CarDealershipInfo[d][cdRadius];
new test = floatround(radius), test1 = floatround(radiusex);
? ? ? ? ? ? if (CarDealershipInfo[d][cdRadius] > radius)
? ? ? ? {
new cost = ( test - test1 ) * ( test1 * 1000 );
if(GetPVarInt(playerid, "Cash") < cost)
{
? ? ? ? ? ? ? ? ? ? format(string, sizeof(string), "ERROR: You do not have enough money for this upgrade ($%d).",cost);
? ? ? ? ? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, string);
? ? ? ? ? ? ? ? ? ? return 1;
}
format(string, sizeof(string), " Car Dealership radius upgraded from %.1f to %.1f for $%d.",radiusex, radius, cost);
? ? ? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, string);
? ? ? ? ? ? CarDealershipInfo[d][cdRadius] = radius;
? ? ? ? ? ? format(string,128,"Car Dealership %s\nOwner: %s\nRadius: %.1f\nID: %d", CarDealershipInfo[d][cdMessage], CarDealershipInfo[d][cdOwner], CarDealershipInfo[d][cdRadius], d);
? ? ? ? ? ? UpdateDynamic3DTextLabelText(CarDealershipInfo[d][cdTextLabel], COLOR_GREEN, string);
? ? ? ? ? ? new listitems[] = "1 Vehicle Spawn\n2 Radius\n3 Dealership Name\n4 Price";
? ? ShowPlayerDialog(playerid,DIALOG_CDUPGRADE,DIALOG_STYLE_LIST,"Choose an item to continue", listitems,"Select","Cancel");
? ? SavecDealerships();
? ? ? ? }
}
else
{
? ? new listitems[] = "1 Vehicle Spawn\n2 Radius\n3 Dealership Name\n4 Price";
ShowPlayerDialog(playerid,DIALOG_CDUPGRADE,DIALOG_STYLE_LIST,"Choose an item to continue", listitems,"Select","Cancel");
}
}
else if(dialogid == DIALOG_CDNAME)
{ // car dealership dialog
if(response && GetPVarInt(playerid, "editingcd") != -1)
{
new d;
d = GetPVarInt(playerid, "editingcd");
? ? ? ? ? ? if (!strlen(inputtext))
{
? ? SendClientMessageEx(playerid, COLOR_LIGHTRED, "** You must type a name **");
? ? ? ? ? ? ShowPlayerDialog(playerid, DIALOG_CDNAME, DIALOG_STYLE_INPUT, "Car Dealership:", " Choose the new name:", "Edit", "Back");
? ? ? ? return 1;
}
new cost = strlen(inputtext) * 50;
format(string, sizeof(string), " Car Dealership name upgraded from %s to %s for $%d.", CarDealershipInfo[d][cdMessage], inputtext, cost);
? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, string);
? ? ? ? strmid(CarDealershipInfo[d][cdMessage], inputtext, 0, strlen(inputtext), 255);
? ? ? ? format(string,128,"Car Dealership %s\nOwner: %s\nRadius: %.1f\nID: %d", CarDealershipInfo[d][cdMessage], CarDealershipInfo[d][cdOwner], CarDealershipInfo[d][cdRadius], d);
? ? ? ? UpdateDynamic3DTextLabelText(CarDealershipInfo[d][cdTextLabel], COLOR_GREEN, string);
? ? ? ? new listitems[] = "1 Vehicle Spawn\n2 Radius\n3 Dealership Name\n4 Price";
ShowPlayerDialog(playerid,DIALOG_CDUPGRADE,DIALOG_STYLE_LIST,"Choose an item to continue", listitems,"Select","Cancel");
SavecDealerships();
}
else
{
? ? new listitems[] = "1 Vehicle Spawn\n2 Radius\n3 Dealership Name\n4 Price";
ShowPlayerDialog(playerid,DIALOG_CDUPGRADE,DIALOG_STYLE_LIST,"Choose an item to continue", listitems,"Select","Cancel");
}
}
else if(dialogid == DIALOG_CDEDITCARS)
{ // car dealership dialog
if(response && GetPVarInt(playerid, "editingcd") != -1)
{
new cdvid;
? ? ? ? ? ? if (IsNumeric(inputtext))
? ? ? ? {
? ? ? ? ? ? cdvid = strval(inputtext);
? ? ? ? ? ? if(CarDealershipInfo[GetPVarInt(playerid, "editingcd")][cdVehicleModel][cdvid-1])
? ? ? ? ? ? {
? ? ? ? ? ? ? ? SetPVarInt(playerid, "editingcdveh", cdvid-1);
? ? ? ? ? ? ? ? new listitems[] = "1 Edit Model\n2 Edit Cost\n3 Edit Park\n4 Delete Vehicle";
? ? ? ? ShowPlayerDialog(playerid,DIALOG_CDEDITONE,DIALOG_STYLE_LIST,"Car Dealership:", listitems,"Select","Cancel");
}
? ? ? ? }
}
else
{
? ? new listitems[] = "1 New Vehicle\n2 My Vehicles\n3 Upgrade\n4 Till";
ShowPlayerDialog(playerid,DIALOG_CDEDIT,DIALOG_STYLE_LIST,"Choose an item to continue", listitems,"Select","Cancel");
}
}
else if(dialogid == DIALOG_CDEDITONE)
{ // car dealership dialog
if(response && GetPVarInt(playerid, "editingcd") != -1 && GetPVarInt(playerid, "editingcdveh") != -1)
{
? ? ? ? ? ? if(listitem == 0) // Edit Model
{
? ? ? ? ? ? ShowPlayerDialog(playerid, DIALOG_CDEDITMODEL, DIALOG_STYLE_INPUT, "Car Dealership:", " Choose the new model id:", "Edit", "Back");
? ? ? ? }
? ? ? ? else if(listitem == 1) // Edit Cost
{
? ? ? ? ? ? ShowPlayerDialog(playerid, DIALOG_CDEDITCOST, DIALOG_STYLE_INPUT, "Car Dealership:", " Choose the new price of the car:", "Edit", "Back");
? ? ? ? }
? ? ? ? else if(listitem == 2) // Edit Park
{
PutPlayerInVehicle(playerid, CarDealershipInfo[GetPVarInt(playerid, "editingcd")][cdVehicleId][GetPVarInt(playerid, "editingcdveh")], 0);
? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GRAD2, " Please stand where you want to park the vehicle.");
SendClientMessageEx(playerid, COLOR_GRAD2, " Once ready press the fire button.");
SetPVarInt(playerid, "editingcdvehpos", 1);
? ? ? ? }
? ? ? ? else if(listitem == 3) // Delete Vehicle
{
? ? ? ? ? ? format(string, sizeof(string), "Are you sure you want to delete this %s?\nNote: You will not get any refounds.",
GetVehicleName(CarDealershipInfo[GetPVarInt(playerid, "editingcd")][cdVehicleId][GetPVarInt(playerid, "editingcdveh")]));
? ? ? ? ShowPlayerDialog(playerid,DIALOG_CDDELVEH,DIALOG_STYLE_MSGBOX,"Warning:",string,"Ok","Cancel");
? ? ? ? }
}
else
{
? ? ? ? ? ? SavecDealerships();
? ? ? ? ? ? SetPVarInt(playerid, "editingcdveh", -1);
}
}
? ? else if(dialogid == DIALOG_CDEDITMODEL)
{ // car dealership dialog
if(response && GetPVarInt(playerid, "editingcd") != -1 && GetPVarInt(playerid, "editingcdveh") != -1)
{
new modelid, d, v;
new text_info[128];
d = GetPVarInt(playerid, "editingcd");
v = GetPVarInt(playerid, "editingcdveh");
? ? ? ? ? ? if (IsNumeric(inputtext))
? ? ? ? {
? ? ? ? ? ? modelid = strval(inputtext);
? ? ? ? ? ? if(modelid < 400 || modelid > 611) { SendClientMessageEx(playerid, COLOR_GREY, "? Vehicle Number can't be below 400 or above 611 !"); return 1; }
? ? ? ? ? ? CarDealershipInfo[d][cdVehicleModel][v] = modelid;
? ? ? ? ? ? DestroyDynamic3DTextLabel(CarDealershipInfo[d][cdVehicleLabel][v]);
? ? ? ? ? ? DestroyVehicle(CarDealershipInfo[d][cdVehicleId][v]);
? ? ? ? ? ? new carcreated;
? ? ? ? ? ? carcreated = CreateVehicleEx(CarDealershipInfo[d][cdVehicleModel][v], CarDealershipInfo[d][cdVehicleSpawnX][v], CarDealershipInfo[d][cdVehicleSpawnY][v], CarDealershipInfo[d][cdVehicleSpawnZ][v], CarDealershipInfo[d][cdVehicleSpawnAngle][v], 0, 0, 6);
? ? ? ? format(text_info, sizeof(text_info),"%s For Sale\nPrice: %d", GetVehicleName(carcreated), CarDealershipInfo[d][cdVehicleCost][v]);
? ? ? ? ? ? ? ? CarDealershipInfo[d][cdVehicleLabel][v] = CreateDynamic3DTextLabel(text_info,COLOR_LIGHTBLUE,0.0, 0.0, 0.0,8.0,INVALID_PLAYER_ID,carcreated);
? ? ? ? ? ? CarDealershipInfo[d][cdVehicleId][v] = carcreated;
? ? ? ? ? ? new listitems[] = "1 Edit Model\n2 Edit Cost\n3 Edit Park\n4 Delete Vehicle";
? ? ShowPlayerDialog(playerid,DIALOG_CDEDITONE,DIALOG_STYLE_LIST,"Car Dealership:", listitems,"Select","Cancel");
? ? SavecDealerships();
? ? ? ? }
}
else
{
? ? new listitems[] = "1 Edit Model\n2 Edit Cost\n3 Edit Park\n4 Delete Vehicle";
ShowPlayerDialog(playerid,DIALOG_CDEDITONE,DIALOG_STYLE_LIST,"Car Dealership:", listitems,"Select","Cancel");
}
}
else if(dialogid == DIALOG_CDEDITCOST)
{ // car dealership dialog
if(response && GetPVarInt(playerid, "editingcd") != -1 && GetPVarInt(playerid, "editingcdveh") != -1)
{
new price, d, v;
new text_info[128];
d = GetPVarInt(playerid, "editingcd");
v = GetPVarInt(playerid, "editingcdveh");
? ? ? ? ? ? if (IsNumeric(inputtext))
? ? ? ? {
? ? ? ? ? ? price = strval(inputtext);
? ? ? ? ? ? CarDealershipInfo[d][cdVehicleCost][v] = price;
? ? ? ? ? ? format(text_info, sizeof(text_info), "%%s For Sale\nPrice: %d", GetVehicleName(CarDealershipInfo[d][cdVehicleId][v]), CarDealershipInfo[d][cdVehicleCost][v]);
? ? ? ? ? ? UpdateDynamic3DTextLabelText(CarDealershipInfo[d][cdVehicleLabel][v], COLOR_LIGHTBLUE, text_info);
? ? ? ? ? ? new listitems[] = "1 Edit Model\n2 Edit Cost\n3 Edit Park\n4 Delete Vehicle";
? ? ShowPlayerDialog(playerid,DIALOG_CDEDITONE,DIALOG_STYLE_LIST,"Car Dealership:", listitems,"Select","Cancel");
? ? SavecDealerships();
? ? ? ? }
}
else
{
? ? new listitems[] = "1 Edit Model\n2 Edit Cost\n3 Edit Park\n4 Delete Vehicle";
ShowPlayerDialog(playerid,DIALOG_CDEDITONE,DIALOG_STYLE_LIST,"Car Dealership:", listitems,"Select","Cancel");
}
}
else if(dialogid == DIALOG_CDDELVEH)
{ // car dealership dialog
if(response && GetPVarInt(playerid, "editingcd") != -1 && GetPVarInt(playerid, "editingcdveh") != -1)
{
DestroyCarDealershipVehicle(GetPVarInt(playerid, "editingcd"), GetPVarInt(playerid, "editingcdveh"));
SavecDealerships();
}
else
{
? ? new listitems[] = "1 Edit Model\n2 Edit Cost\n3 Edit Park\n4 Delete Vehicle";
ShowPlayerDialog(playerid,DIALOG_CDEDITONE,DIALOG_STYLE_LIST,"Car Dealership:", listitems,"Select","Cancel");
}
}
//=========================================================================//
else if(dialogid == DIALOG_CDEDITPARK)
{ // car dealership dialog
if(response && GetPVarInt(playerid, "editingcd") != -1 && GetPVarInt(playerid, "editingcdveh") != -1 &&? GetPVarInt(playerid, "editingcdvehpos") == 1 || GetPVarInt(playerid, "editingcdvehnew"))
{
new Float: x, Float: y, Float: z, Float: a;
new d, v, text_info[128];
d = GetPVarInt(playerid, "editingcd");
v = GetPVarInt(playerid, "editingcdveh");
GetVehiclePos(CarDealershipInfo[d][cdVehicleId][v], x, y, z);
? ? ? ? GetVehicleZAngle(CarDealershipInfo[d][cdVehicleId][v], a);
if(IsPlayerInRangeOfPoint(playerid, CarDealershipInfo[d][cdRadius], CarDealershipInfo[d][cdEntranceX], CarDealershipInfo[d][cdEntranceY], CarDealershipInfo[d][cdEntranceZ]))
? ? {
? ? CarDealershipInfo[d][cdVehicleSpawnX][v] = x;
? ? ? ? ? ? ? ? CarDealershipInfo[d][cdVehicleSpawnY][v] = y;
? ? ? ? ? ? ? ? CarDealershipInfo[d][cdVehicleSpawnZ][v] = z;
? ? ? ? ? ? ? ? CarDealershipInfo[d][cdVehicleSpawnAngle][v] = a;
? ? ? ? ? ? ? ? SetPVarInt(playerid, "editingcdvehpos", 0);
? ? ? ? ? ? ? ? SetPVarInt(playerid, "editingcdvehnew", 0);
? ? ? ? ? ? ? ? DestroyDynamic3DTextLabel(CarDealershipInfo[d][cdVehicleLabel][v]);
? ? ? ? ? ? DestroyVehicle(CarDealershipInfo[d][cdVehicleId][v]);
? ? ? ? ? ? new carcreated;
? ? ? ? ? ? carcreated = CreateVehicleEx(CarDealershipInfo[d][cdVehicleModel][v], CarDealershipInfo[d][cdVehicleSpawnX][v], CarDealershipInfo[d][cdVehicleSpawnY][v], CarDealershipInfo[d][cdVehicleSpawnZ][v], CarDealershipInfo[d][cdVehicleSpawnAngle][v], 0, 0, 6);
? ? ? ? format(text_info, sizeof(text_info), "%s For Sale\nPrice: %d", GetVehicleName(carcreated), CarDealershipInfo[d][cdVehicleCost][v]);
? ? ? ? ? ? ? ? CarDealershipInfo[d][cdVehicleLabel][v] = CreateDynamic3DTextLabel(text_info,COLOR_LIGHTBLUE,0.0, 0.0, 0.0,8.0,INVALID_PLAYER_ID,carcreated);
? ? ? ? ? ? CarDealershipInfo[d][cdVehicleId][v] = carcreated;
? ? ? ? ? ? TogglePlayerControllable(playerid, true);
? ? ? ? ? ? new listitems[] = "1 Edit Model\n2 Edit Cost\n3 Edit Park\n4 Delete Vehicle";
? ? ShowPlayerDialog(playerid,DIALOG_CDEDITONE,DIALOG_STYLE_LIST,"Car Dealership Editor:", listitems,"Select","Cancel");
? ? SavecDealerships();
}
else
{
? ? ? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, "ERROR: You are out of this Car Dealership radius, please try again.");
? ? ? ? ? ? ? ? TogglePlayerControllable(playerid, true);
}
}
else if(response && GetPVarInt(playerid, "editingcd") != -1 && GetPVarInt(playerid, "editingcdvehpos") == 2)
{
new Float: x, Float: y, Float: z, Float: a;
new d;
GetPlayerPos(playerid,x,y,z);
? ? ? ? GetPlayerFacingAngle(playerid, a);
d = GetPVarInt(playerid, "editingcd");
if(IsPlayerInRangeOfPoint(playerid, CarDealershipInfo[d][cdRadius], CarDealershipInfo[d][cdEntranceX], CarDealershipInfo[d][cdEntranceY], CarDealershipInfo[d][cdEntranceZ]))
? ? {
? ? CarDealershipInfo[d][cdVehicleSpawn][0] = x;
? ? ? ? ? ? ? ? CarDealershipInfo[d][cdVehicleSpawn][1] = y;
? ? ? ? ? ? ? ? CarDealershipInfo[d][cdVehicleSpawn][2] = z;
? ? ? ? ? ? ? ? CarDealershipInfo[d][cdVehicleSpawn][3] = a;
? ? ? ? ? ? ? ? SetPVarInt(playerid, "editingcdvehpos", 0);
? ? ? ? ? ? TogglePlayerControllable(playerid, true);
? ? ? ? ? ? new listitems[] = "1 Vehicle Spawn\n2 Radius\n3 Dealership Name\n4 Price";
? ? ShowPlayerDialog(playerid,DIALOG_CDUPGRADE,DIALOG_STYLE_LIST,"Car Dealership Editor:", listitems,"Select","Cancel");
? ? SavecDealerships();
}
else
{
? ? ? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, "ERROR: You are out of this Car Dealership radius, please try again.");
? ? ? ? ? ? ? ? TogglePlayerControllable(playerid, true);
}
}
else if(!response && GetPVarInt(playerid, "editingcd") != -1 && GetPVarInt(playerid, "editingcdvehpos") == 1)
{
? ? ? ? ? ? new listitems[] = "1 Edit Model\n2 Edit Cost\n3 Edit Park\n4 Delete Vehicle";
ShowPlayerDialog(playerid,DIALOG_CDEDITONE,DIALOG_STYLE_LIST,"Car Dealership Editor:", listitems,"Select","Cancel");
TogglePlayerControllable(playerid, true);
SetPVarInt(playerid, "editingcdvehpos", 0);
}
else if(!response && GetPVarInt(playerid, "editingcd") != -1 && GetPVarInt(playerid, "editingcdvehpos") == 2)
{
? ? ? ? ? ? new listitems[] = "1 Vehicle Spawn\n2 Radius\n3 Dealership Name\n4 Price";
? ? ShowPlayerDialog(playerid,DIALOG_CDUPGRADE,DIALOG_STYLE_LIST,"Car Dealership Editor:", listitems,"Select","Cancel");
TogglePlayerControllable(playerid, true);
SetPVarInt(playerid, "editingcdvehpos", 0);
}
}
else if(dialogid == DIALOG_CDNEWVEH)
{ // car dealership dialog
if(response && GetPVarInt(playerid, "editingcd") != -1)
{
new modelid, d;
new Float: x, Float: y, Float: z, Float: a;
new text_info[128];
d = GetPVarInt(playerid, "editingcd");
GetPlayerPos(playerid,x,y,z);
? ? ? ? GetPlayerFacingAngle(playerid, a);
? ? ? ? if (!IsNumeric(inputtext)) return SendClientMessageEx(playerid, COLOR_GRAD1, "ERROR: Model ID must be numbers.");
? ? ? ? ? ? if (IsPlayerInRangeOfPoint(playerid, CarDealershipInfo[d][cdRadius], CarDealershipInfo[d][cdEntranceX], CarDealershipInfo[d][cdEntranceY], CarDealershipInfo[d][cdEntranceZ]))
? ? ? ? {
? ? ? ? ? ? modelid = strval(inputtext);
? ? ? ? ? ? if(modelid < 400 || modelid > 611) { SendClientMessageEx(playerid, COLOR_GREY, "? Vehicle Number can't be below 400 or above 611 !"); return 1; }
? ? ? ? ? ? new cdvehicleid = CreateCarDealershipVehicle(d, modelid, x, y, z, a, 1337);
? ? ? ? ? ? if(cdvehicleid == -1)
? ? ? ? {
? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, "ERROR: Car couldn't be created.");
? ? ? ? }
? ? ? ? ? ? else
? ? ? ? ? ? {
PutPlayerInVehicle(playerid, CarDealershipInfo[d][cdVehicleId][cdvehicleid], 0);
? ? ? ? ? ? ? ? ? ? format(text_info, sizeof(text_info), " SYSTEM: Car dealership vehicle created (ID %d)", cdvehicleid-1);
? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GRAD1, text_info);
? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GRAD2, " Please stand where you want to add your new vehicle.");
? ? SendClientMessageEx(playerid, COLOR_GRAD2, " Once ready press the fire button.");
? ? SetPVarInt(playerid, "editingcdvehnew", 1);
? ? ? ? ? ? SetPVarInt(playerid, "editingcdveh", cdvehicleid);
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? else
? ? ? ? {
? ? ? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, "ERROR: You are out of this Car Dealership radius, please try again.");
? ? ? ? ? ? ? ? TogglePlayerControllable(playerid, true);
? ? ? ? }
}
else
{
? ? ? ? ? ? TogglePlayerControllable(playerid, true);
SetPVarInt(playerid, "editingcd", -1);
}
}
else if(dialogid == DIALOG_CDBUY)
{
? ? // Account Eating Bug Fix
? ? if(!IsPlayerInAnyVehicle(playerid))
{
? ? TogglePlayerControllable(playerid, 1);
SendClientMessageEx(playerid,COLOR_GRAD2,"You need to be in the vehicle you wish to purchase.");
return 1;
}
new vehicleid = GetPlayerVehicleID(playerid);
new v = GetCarDealershipVehicleId(vehicleid);
new d = GetCarDealershipId(vehicleid);
if(response)
{
for(new b; b < MAX_PLAYERVEHICLES; b)
{
if(PlayerVehicleInfo[playerid][b][pvImpounded] == 1) {
SendClientMessageEx(playerid, COLOR_GRAD1, "ERROR: You cannot buy a new car with a impounded vehicle, you must release the car first.");
RemovePlayerFromVehicle(playerid);
new Float:slx, Float:sly, Float:slz;
GetPlayerPos(playerid, slx, sly, slz);
SetPlayerPos(playerid, slx, sly, slz.2);
TogglePlayerControllable(playerid, 1);
return 1;
}
}
? ? ? ? ? ? if(CarDealershipInfo[d][cdVehicleSpawn][0] == 0.0 && CarDealershipInfo[d][cdVehicleSpawn][1] == 0.0 && CarDealershipInfo[d][cdVehicleSpawn][2] == 0.0)
? ? ? ? ? ? {
SendClientMessageEx(playerid, COLOR_GRAD1, "ERROR: The owner of this Car Dealership hasn't set the purchased vehicles spawn point.");
RemovePlayerFromVehicle(playerid);
new Float:slx, Float:sly, Float:slz;
GetPlayerPos(playerid, slx, sly, slz);
SetPlayerPos(playerid, slx, sly, slz.2);
TogglePlayerControllable(playerid, 1);
return 1;
? ? ? ? ? ? }
? ? ? ? ? ? if(IsVIPModel(vehicleid) && (PlayerInfo[playerid][pDonateRank] == 0 || PlayerInfo[playerid][pTempVIP] > 0))
? ? ? ? ? ? {
? ? ? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, "ERROR: Only VIP's can own that type of vehicles.");
? ? ? ? ? ? ? ? RemovePlayerFromVehicle(playerid);
? ? ? ? ? ? ? ? new Float:slx, Float:sly, Float:slz;
GetPlayerPos(playerid, slx, sly, slz);
SetPlayerPos(playerid, slx, sly, slz.2);
? ? ? ? ? ? ? ? TogglePlayerControllable(playerid, 1);
? ? ? ? ? ? ? ? return 1;
? ? ? ? ? ? }
? ? ? ? ? ? new playervehicleid = GetPlayerFreeVehicleId(playerid);
? ? ? ? ? ? new carsamount = GetPlayerVehicleCount(playerid);
? ? ? ? ? ? if((PlayerInfo[playerid][pDonateRank] == 0 || PlayerInfo[playerid][pTempVIP] > 0) && carsamount >= 2)
{
? ? ? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, "ERROR: You can't have more cars.");
? ? ? ? ? ? ? ? RemovePlayerFromVehicle(playerid);
? ? ? ? ? ? ? ? new Float:slx, Float:sly, Float:slz;
GetPlayerPos(playerid, slx, sly, slz);
SetPlayerPos(playerid, slx, sly, slz.2);
? ? ? ? ? ? ? ? TogglePlayerControllable(playerid, 1);
? ? ? ? ? ? ? ? return 1;
}
? ? ? ? ? ? if(PlayerInfo[playerid][pDonateRank] == 1 && carsamount >= 3)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, "ERROR: You can't have more cars, VIP Rank 1 can only own 1 extra car.");
? ? ? ? ? ? ? ? RemovePlayerFromVehicle(playerid);
? ? ? ? ? ? ? ? new Float:slx, Float:sly, Float:slz;
GetPlayerPos(playerid, slx, sly, slz);
SetPlayerPos(playerid, slx, sly, slz.2);
? ? ? ? ? ? ? ? TogglePlayerControllable(playerid, 1);
? ? ? ? ? ? ? ? return 1;
? ? ? ? ? ? }
? ? ? ? ? ? if(PlayerInfo[playerid][pDonateRank] == 2 && carsamount >= 4)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, "ERROR: You can't have more cars, VIP Rank 2 can only own 2 extra cars.");
? ? ? ? ? ? ? ? RemovePlayerFromVehicle(playerid);
? ? ? ? ? ? ? ? new Float:slx, Float:sly, Float:slz;
GetPlayerPos(playerid, slx, sly, slz);
SetPlayerPos(playerid, slx, sly, slz.2);
? ? ? ? ? ? ? ? TogglePlayerControllable(playerid, 1);
? ? ? ? ? ? ? ? return 1;
? ? ? ? ? ? }
? ? ? ? ? ? if(PlayerInfo[playerid][pDonateRank] == 3 && carsamount >= 5)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, "ERROR: You can't have more cars, VIP Rank 3 can only own 3 extra cars.");
? ? ? ? ? ? ? ? RemovePlayerFromVehicle(playerid);
? ? ? ? ? ? ? ? new Float:slx, Float:sly, Float:slz;
GetPlayerPos(playerid, slx, sly, slz);
SetPlayerPos(playerid, slx, sly, slz.2);
? ? ? ? ? ? ? ? TogglePlayerControllable(playerid, 1);
? ? ? ? ? ? ? ? return 1;
? ? ? ? ? ? }
? ? if(playervehicleid == -1)
? ? {
? ? ? ? SendClientMessageEx(playerid, COLOR_GREY, "ERROR: You can't have more cars.");
? ? ? ? ? ? ? ? RemovePlayerFromVehicle(playerid);
? ? ? ? ? ? ? ? new Float:slx, Float:sly, Float:slz;
GetPlayerPos(playerid, slx, sly, slz);
SetPlayerPos(playerid, slx, sly, slz.2);
? ? ? ? ? ? ? ? TogglePlayerControllable(playerid, 1);
? ? ? ? ? ? ? ? return 1;
? ? }
? ? new randcolor1 = Random(0, 126);
? ? new randcolor2 = Random(0, 126);
? ? SetPlayerPos(playerid, CarDealershipInfo[d][cdVehicleSpawn][0], CarDealershipInfo[d][cdVehicleSpawn][1], CarDealershipInfo[d][cdVehicleSpawn][2]);
? ? TogglePlayerControllable(playerid, 1);
? ? new cost;
? ? if(PlayerInfo[playerid][pDonateRank] < 1)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? cost = CarDealershipInfo[d][cdVehicleCost][v];
? ? ? ? ? ? if(GetPVarInt(playerid, "Cash") < CarDealershipInfo[d][cdVehicleCost][v])
? ? ? ? ? ? {
SendClientMessageEx(playerid, COLOR_GRAD1, "ERROR: You don't have enough money to buy this.");
RemovePlayerFromVehicle(playerid);
new Float:slx, Float:sly, Float:slz;
GetPlayerPos(playerid, slx, sly, slz);
SetPlayerPos(playerid, slx, sly, slz.2);
return 1;
? ? ? ? ? ? }
? ? ? ? ? ? ? ? format(string, sizeof(string), " Thank you for buying at %s.", CarDealershipInfo[d][cdMessage]);
? ? ? ? SendClientMessageEx(playerid, COLOR_GRAD1, string);
? ? ? ? SetPVarInt(playerid, "Cash", GetPVarInt(playerid, "Cash")-CarDealershipInfo[d][cdVehicleCost][v]);
? ? ? ? CarDealershipInfo[d][cdTill] = ( CarDealershipInfo[d][cdVehicleCost][v] * 40 ) / ( 100 );
? ? ? ? }
? ? ? ? else
? ? ? ? {
cost = ( CarDealershipInfo[d][cdVehicleCost][v] * 80 ) / ( 100 );
? ? ? ? ? ? if(GetPVarInt(playerid, "Cash") < cost)
? ? ? ? ? ? {
SendClientMessageEx(playerid, COLOR_GRAD1, "ERROR: You don't have enough money to buy this.");
RemovePlayerFromVehicle(playerid);
new Float:slx, Float:sly, Float:slz;
GetPlayerPos(playerid, slx, sly, slz);
SetPlayerPos(playerid, slx, sly, slz.2);
return 1;
? ? ? ? ? ? }
? ? ? ? ? ? ? ? format(string, sizeof(string), " Thank you for buying at %s.", CarDealershipInfo[d][cdMessage]);
? ? ? ? SendClientMessageEx(playerid, COLOR_GRAD1, string);
? ? ? ? SetPVarInt(playerid, "Cash", GetPVarInt(playerid, "Cash") - cost );
CarDealershipInfo[d][cdTill] = cost;
? ? }
? ? ? ? ? ? new car = CreatePlayerVehicle(playerid, playervehicleid, CarDealershipInfo[d][cdVehicleModel][v], CarDealershipInfo[d][cdVehicleSpawn][0], CarDealershipInfo[d][cdVehicleSpawn][1], CarDealershipInfo[d][cdVehicleSpawn][2], CarDealershipInfo[d][cdVehicleSpawn][3], randcolor1, randcolor2, cost);
Gas[car] =100.0;
SetTimerEx("PutPlayerInVeh", 2000, 0, "dd", playerid, car);
? ? ? ? ? ? SavecDealerships();
}
else
{
? ? ? ? ? ? RemovePlayerFromVehicle(playerid);
? ? ? ? ? ? new Float:slx, Float:sly, Float:slz;
GetPlayerPos(playerid, slx, sly, slz);
SetPlayerPos(playerid, slx, sly, slz.2);
? ? ? ? ? ? TogglePlayerControllable(playerid, 1);
return 1;
}
}
else if(dialogid == DIALOG_CDSELL)
{
if(response)
{
if(GetPVarInt(playerid, "editingcd") == -1) return 1;
? ? ? ? ? ? SetPVarInt(playerid, "Cash", GetPVarInt(playerid, "Cash") (CarDealershipInfo[GetPVarInt(playerid, "editingcd")][cdPrice] / 2));
SellCarDealership(GetPVarInt(playerid, "editingcd"));
PlayerPlayMusic(playerid);
format(string, sizeof(string), "Car Dealership successfully sold for %d.", CarDealershipInfo[GetPVarInt(playerid, "editingcd")][cdPrice] / 2);
SendClientMessageEx(playerid, COLOR_WHITE, string);
}
else
{
? ? ? ? ? ? SetPVarInt(playerid, "editingcd", -1);
return 1;
}
}
//=========================================================================//
//CAR DEALERSHIP SYSTEM BY Unknown
//------------------------------------------------------------------------------
stock CreateCarDealership(Float: enx, Float: eny, Float: enz, Float: radius, price, message[])
{
new dealershipid = GetFreeCarDealership();
if(dealershipid == -1) return -1;
new text_info[128];
CarDealershipInfo[dealershipid][cdEntranceX] = enx;
CarDealershipInfo[dealershipid][cdEntranceY] = eny;
CarDealershipInfo[dealershipid][cdEntranceZ] = enz;
CarDealershipInfo[dealershipid][cdRadius] = radius;
CarDealershipInfo[dealershipid][cdPrice] = price;
strmid(CarDealershipInfo[dealershipid][cdMessage], message, 0, strlen(message), 255);
CarDealershipInfo[dealershipid][cdPickupID] = CreateDynamicPickup(1239, 1, CarDealershipInfo[dealershipid][cdEntranceX], CarDealershipInfo[dealershipid][cdEntranceY], CarDealershipInfo[dealershipid][cdEntranceZ]);
format(text_info, sizeof(text_info), "Car Dealership %s For Sale\nPrice: %d\nRadius: %.1f\nID: %d", CarDealershipInfo[dealershipid][cdMessage], CarDealershipInfo[dealershipid][cdPrice], CarDealershipInfo[dealershipid][cdRadius], dealershipid);
? ? CarDealershipInfo[dealershipid][cdTextLabel] = CreateDynamic3DTextLabel(text_info,COLOR_RED,CarDealershipInfo[dealershipid][cdEntranceX], CarDealershipInfo[dealershipid][cdEntranceY], CarDealershipInfo[dealershipid][cdEntranceZ].75,3.0,INVALID_PLAYER_ID,INVALID_VEHICLE_ID,1);
? ? SavecDealerships();
? ? return dealershipid;
}
stock DestroyCarDealership(dealershipid)
{
new string[30];
CarDealershipInfo[dealershipid][cdEntranceX] = 0.0;
CarDealershipInfo[dealershipid][cdEntranceY] = 0.0;
CarDealershipInfo[dealershipid][cdEntranceZ] = 0.0;
CarDealershipInfo[dealershipid][cdRadius] = 0.0;
CarDealershipInfo[dealershipid][cdTill] = 0;
CarDealershipInfo[dealershipid][cdOwned] = 0;
CarDealershipInfo[dealershipid][cdPrice] = 0;
format(string, sizeof(string), "None");
strmid(CarDealershipInfo[dealershipid][cdOwner], string, 0, strlen(string), 255);
format(string, sizeof(string), "None");
strmid(CarDealershipInfo[dealershipid][cdMessage], string, 0, strlen(string), 255);
DestroyDynamic3DTextLabel(CarDealershipInfo[dealershipid][cdTextLabel]);
DestroyDynamicPickup(CarDealershipInfo[dealershipid][cdPickupID]);
CarDealershipInfo[dealershipid][cdPickupID] = 0;
CarDealershipInfo[dealershipid][cdTextLabel] = Text3D:INVALID_3DTEXT_ID;
CarDealershipInfo[dealershipid][cdVehicleSpawn][0] = 0.0;
? ? CarDealershipInfo[dealershipid][cdVehicleSpawn][1] = 0.0;
? ? CarDealershipInfo[dealershipid][cdVehicleSpawn][2] = 0.0;
? ? CarDealershipInfo[dealershipid][cdVehicleSpawn][3] = 0.0;
for(new v = 0; v < MAX_DEALERSHIPVEHICLES; v)
{
if (CarDealershipInfo[dealershipid][cdVehicleModel][v] != 0)
{
? ? ? ? DestroyCarDealershipVehicle(dealershipid, v);
}
}
SavecDealerships();
}
stock GetFreeCarDealership()
{
? ? new
i = 0;
while (i < MAX_CARDEALERSHIPS && CarDealershipInfo[i][cdEntranceX] != 0.0 && CarDealershipInfo[i][cdEntranceY] != 0.0)
{
i;
}
if (i == MAX_CARDEALERSHIPS) return -1;
return i;
}
stock SetPlayerOwnerOfCD(playerid, dealershipid)
{
new owner[MAX_PLAYER_NAME];
CarDealershipInfo[dealershipid][cdOwned] = 1;
GetPlayerName(playerid, owner, sizeof(owner));
strmid(CarDealershipInfo[dealershipid][cdOwner], owner, 0, strlen(owner), 255);
new text_info[128];
format(text_info, sizeof(text_info), "Car Dealership %s\nOwner: %s\nRadius: %.1f\nID: %d", CarDealershipInfo[dealershipid][cdMessage], CarDealershipInfo[dealershipid][cdOwner], CarDealershipInfo[dealershipid][cdRadius], dealershipid);
UpdateDynamic3DTextLabelText(CarDealershipInfo[dealershipid][cdTextLabel], COLOR_GREEN, text_info);
SavecDealerships();
}
stock SellCarDealership(dealershipid)
{
CarDealershipInfo[dealershipid][cdOwned] = 0;
CarDealershipInfo[dealershipid][cdVehicleSpawn][0] = 0.0;
CarDealershipInfo[dealershipid][cdVehicleSpawn][1] = 0.0;
CarDealershipInfo[dealershipid][cdVehicleSpawn][2] = 0.0;
CarDealershipInfo[dealershipid][cdVehicleSpawn][3] = 0.0;
strmid(CarDealershipInfo[dealershipid][cdOwner], "No-one", 0, MAX_PLAYER_NAME, 255);
new text_info[128];
format(text_info, sizeof(text_info), "Car Dealership %s For Sale\nPrice: %d\nRadius: %.1f\nID: %d", CarDealershipInfo[dealershipid][cdMessage], CarDealershipInfo[dealershipid][cdPrice], CarDealershipInfo[dealershipid][cdRadius], dealershipid);
UpdateDynamic3DTextLabelText(CarDealershipInfo[dealershipid][cdTextLabel], COLOR_RED, text_info);
SavecDealerships();
}
stock IsPlayerOwnerOfCD(playerid)
{
new owner[MAX_PLAYER_NAME];
GetPlayerName(playerid, owner, sizeof(owner));
for(new d = 0; d < MAX_CARDEALERSHIPS; d)
? ? {
? ? if(strcmp(CarDealershipInfo[d][cdOwner],owner, true ) == 0)
? ? {
return d;
}
}
return -1;
}
stock IsPlayerOwnerOfCDEx(playerid, dealershipid)
{
new owner[MAX_PLAYER_NAME];
GetPlayerName(playerid, owner, sizeof(owner));
if(strcmp(CarDealershipInfo[dealershipid][cdOwner],owner, true ) == 0)
{
? ? return 1;
}
return 0;
}
stock CreateCarDealershipVehicle(dealershipid, modelid, Float: x, Float: y, Float: z, Float: a, price)
{
? ? new cdvehicleid = GetFreeCarDealershipVehicleId(dealershipid);
? ? if(cdvehicleid == -1) return -1;
? ? new text_info[128];
? ? CarDealershipInfo[dealershipid][cdVehicleModel][cdvehicleid] = modelid;
? ? CarDealershipInfo[dealershipid][cdVehicleCost][cdvehicleid] = price;
? ? CarDealershipInfo[dealershipid][cdVehicleSpawnX][cdvehicleid] = x;
? ? CarDealershipInfo[dealershipid][cdVehicleSpawnY][cdvehicleid] = y;
? ? CarDealershipInfo[dealershipid][cdVehicleSpawnZ][cdvehicleid] = z;
? ? CarDealershipInfo[dealershipid][cdVehicleSpawnAngle][cdvehicleid] = a;
? ? new carcreated = CreateVehicleEx(modelid, x, y, z, a, 0, 0, 6);
? ? format(text_info, sizeof(text_info), "%s For Sale\nPrice: %d\nID: %d", GetVehicleName(carcreated), CarDealershipInfo[dealershipid][cdVehicleCost][cdvehicleid], cdvehicleid);
? ? CarDealershipInfo[dealershipid][cdVehicleLabel][cdvehicleid] = CreateDynamic3DTextLabel(text_info,COLOR_LIGHTBLUE,0.0, 0.0, 0.0,5.0,INVALID_PLAYER_ID,carcreated,1);
CarDealershipInfo[dealershipid][cdVehicleId][cdvehicleid] = carcreated;
SavecDealerships();
? ? return cdvehicleid;
}
stock DestroyCarDealershipVehicle(dealershipid, cdvehicleid)
{
? ? CarDealershipInfo[dealershipid][cdVehicleModel][cdvehicleid] = 0;
? ? CarDealershipInfo[dealershipid][cdVehicleCost][cdvehicleid] = 0;
? ? CarDealershipInfo[dealershipid][cdVehicleSpawnX][cdvehicleid] = 0.0;
? ? CarDealershipInfo[dealershipid][cdVehicleSpawnY][cdvehicleid] = 0.0;
? ? CarDealershipInfo[dealershipid][cdVehicleSpawnZ][cdvehicleid] = 0.0;
? ? CarDealershipInfo[dealershipid][cdVehicleSpawnAngle][cdvehicleid] = 0.0;
? ? DestroyDynamic3DTextLabel(CarDealershipInfo[dealershipid][cdVehicleLabel][cdvehicleid]);
? ? DestroyVehicle(CarDealershipInfo[dealershipid][cdVehicleId][cdvehicleid]);
? ? CarDealershipInfo[dealershipid][cdVehicleLabel][cdvehicleid] = Text3D:INVALID_3DTEXT_ID;
? ? CarDealershipInfo[dealershipid][cdVehicleId][cdvehicleid] = 0;
}
stock GetFreeCarDealershipVehicleId(dealershipid)
{
? ? new
i = 0;
while (i < MAX_DEALERSHIPVEHICLES && CarDealershipInfo[dealershipid][cdVehicleModel][i] != 0)
{
i;
}
if (i == MAX_DEALERSHIPVEHICLES) return -1;
return i;
}
stock GetCarDealershipVehicleId(vehicleid)
{
? ? for(new d = 0; d < MAX_CARDEALERSHIPS; d)
? ? {
? ? ? ? for(new v = 0; v < MAX_DEALERSHIPVEHICLES; v)
? ? ? ? {
? ? ? ? ? ? if(CarDealershipInfo[d][cdVehicleId][v] == vehicleid)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? return v;
? ? ? ? ? ? }
}
? ? }
? ? return -1;
}
stock GetCarDealershipId(vehicleid)
{
? ? for(new d = 0; d < MAX_CARDEALERSHIPS; d)
? ? {
? ? ? ? for(new v = 0; v < MAX_DEALERSHIPVEHICLES; v)
? ? ? ? {
? ? ? ? ? ? if(CarDealershipInfo[d][cdVehicleId][v] == vehicleid)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? return d;
? ? ? ? ? ? }
}
? ? }
? ? return -1;
}
//=========================================================================//
|
|
|
Colour Embedding Issue |
Posted by: Torque - 2021-01-21, 11:14 PM - Forum: Support
- Replies (3)
|
 |
It seems that there's a bug with colour embedding, whether it be dialogs or chat text.
It seems the colour is "leaking" into the next word in which a colour has already been set for.
|
|
|
How to optimize this code |
Posted by: RhaegarX - 2021-01-21, 08:30 PM - Forum: Pawn Scripting
- Replies (5)
|
 |
I have this enum that stores the information of organizations stored with mysql.
PHP Code: enum oInfo { oID, oName[50], oMoney, oMaterials, oMaconha, oCrack, oCocaina, oOrgVip, oOrgVipTime, Float:oPosX, Float:oPosY, Float:oPosZ, Float:oPosA, oInterior, oWorld, oSkinLider, oSkinLiderF, oSkinMember, oSkinMember2, oSkinMember3, oSkinMember4, oSkinMember5, oSkinMemberF, oSalaryLider, oSalaryMember, oSalaryMember2, oSalaryMember3, oSalaryMember4, oSalaryMember5, oLider[MAX_PLAYER_NAME], oSubLider[MAX_PLAYER_NAME], oMember1[MAX_PLAYER_NAME], oMember2[MAX_PLAYER_NAME], oMember3[MAX_PLAYER_NAME], oMember4[MAX_PLAYER_NAME], oMember5[MAX_PLAYER_NAME], oMember6[MAX_PLAYER_NAME], oMember7[MAX_PLAYER_NAME], oMember8[MAX_PLAYER_NAME], oMember9[MAX_PLAYER_NAME], oMember10[MAX_PLAYER_NAME], oMember11[MAX_PLAYER_NAME], oMember12[MAX_PLAYER_NAME], oMember13[MAX_PLAYER_NAME], oMember14[MAX_PLAYER_NAME], oMember15[MAX_PLAYER_NAME], oMember16[MAX_PLAYER_NAME], oMember17[MAX_PLAYER_NAME], oMember18[MAX_PLAYER_NAME], oMember19[MAX_PLAYER_NAME], oMember20[MAX_PLAYER_NAME], oMember21[MAX_PLAYER_NAME], oMember22[MAX_PLAYER_NAME], oMember23[MAX_PLAYER_NAME], oMember24[MAX_PLAYER_NAME], oMember25[MAX_PLAYER_NAME], oMember26[MAX_PLAYER_NAME], oMember27[MAX_PLAYER_NAME], oMember28[MAX_PLAYER_NAME], oMember29[MAX_PLAYER_NAME], oMember30[MAX_PLAYER_NAME]
}; new OrgInfo[MAX_ORGS][oInfo];
There is a situation, in which I will display all the members of the organization, however as we can see there are more than 30 members and the current way in which I do this is to write the code for each member.
PHP Code: format(string, sizeof(string), "Member 1: %s\n", OrgInfo[org][oMember1]); strcat(membersList, string);
format(string, sizeof(string), "Member 2: %s\n", OrgInfo[org][oMember2]); strcat(membersList, string);
.... 30 Code Very Long
ShowPlayerDialog(playerid, DIALOG_ORG_BACK, DIALOG_STYLE_TABLIST_HEADERS, "Membros da Organiza??o", membersList, "Voltar", "Fechar");
I would like to know if there is any way, to access the variable of each member without having to be one by one. Perhaps with the use of some repetition loop? It's possible?
|
|
|
Best practice with timers |
Posted by: RhaegarX - 2021-01-21, 02:16 AM - Forum: Pawn Scripting
- Replies (3)
|
 |
Hello guys!? I would like to ask a question about the use of timers.? Suppose I have several systems that do checks from time to time, the best way would be to create a single timer that does all the checks or create multiple timers to check each thing?? Which way would be the most optimized and least burdensome on the server?
Code 1:
PHP Code: SetTimer("ExecuteAll", 1000, false);
public ExecuteAll() { // Verification 1 // Verification 2 // Verification 3 ... }
Code 2:
PHP Code: SetTimer("Execute1", 1000, false); SetTimer("Execute2", 1000, false); SetTimer("Execute3", 1000, false);
public Execute1() { // Verification 1 } public Execute2() { // Verification 2 } public Execute3() { // Verification 3 }
|
|
|
Ternary Operator Basics |
Posted by: RhaegarX - 2021-01-20, 07:29 PM - Forum: Tutorials
- Replies (4)
|
 |
"Sorry for the bad English, I'm using the translator to do this tutorial."
- What is a ternary operator?
In various situations in programming we need to deal with various scenarios, through conditional structures, such as if, else and switch. However, in some situations we deal with wave situations there are only 2 possible returns.
For example, let's imagine a hypothetical situation, in which if the player is an administrator he wins $ 1500, otherwise he will win $ 500.
We can do this logic using the if and else operator:
PHP Code: if (PlayerData[playerid][pAdmin] > 0)
{? ? ? ? ?
? ? GivePlayerMoney(playerid, 1500);
}
else
{
? ? GivePlayerMoney(playerid, 500);
}
Now notice that we are making a relatively long structure for a simple action, with only two possibilities. Is there no other way to write this code in a simpler way? Yes, there is, and that is what the ternary operator is for:
PHP Code: GivePlayerMoney(playerid, (PlayerData[playerid][pAdmin] > 0 ? 1500 : 500));
Now we did the same action with just one line of code, however let's understand a little bit about how to build a ternary operator.
- How to build a ternary operator?
Building a ternary operator is simple, its own structure is self-explanatory.
PHP Code: (condition ? value if true : value if false)
To better understand, we can see that the '?' acts as an if and the ':' acts as the else.
- In what situations will I use the ternary operator?
This is a relative question, it depends a lot on the type of logic that you will build for your system, but as stated in the first question we will use the ternary operator for situations in which there are only 2 possibilities of return. Remembering that the ternary operator is not limited to returning only number values, but can also return strings and other options.
Example of a string with a ternary operator:
PHP Code: SendClientMessage(playerid, -1, (playerData[playerid][pAdmin] > 0 ? "True" : "false"));
- Problems with ternary operator
The main problem with the ternary operator is its structure, which because it is very compact, its structure can be difficult to read by programmers who are not used to it.
- End
This is my first personal authoring tutorial, i hope you like it and criticism will always be welcome!
|
|
|
TSConnector and some other fce |
Posted by: Ardenis - 2021-01-20, 06:46 PM - Forum: Pawn Scripting
- Replies (1)
|
 |
Hey there
the TS_PokeClient function does not work correctly. When someone joins the game, they poke them ?
let's look at the code
Code: public TSC_OnClientConnect (clientid, nickname [])
{
new str[50];
format(str, sizeof(str), "> %s (%d) has join to our ts3 server", nickname, clientid);
SendClientMessageToAll(-1, str);
TSC_SendClientMessage(clientid, "Yup, here it works");
TSC_PokeClient(clientid, "Welcome"); // But not here, it not poke him but idk why
return 1;
}
http://prntscr.com/xb40i1
https://github.com/maddinat0r/samp-tsconnector/releases
|
|
|
|