Hello if any1 could take a look on this script i got 2 bugs with it 1 rly important
1#When i bought a vehicle its spawn with me in it and the i use /v lock /v sell etc etc it says you dont own a vehicle?humm and also when i use other such of vehicle commands its says the same what can the problem be?
2#When some1 has bought a car and some1 steels it and park it far away the car will be spawned there the last guy putted the char becouse the car are saving or somthing i want it to be parked on the car dealership if the owner of the car hasnt used /v park
Код:
new vehid;
tmp = strtok(cmdtext, idx);
if (!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /destroycdveh [vehicleid]");
return 1;
}
vehid = strval(tmp);
DestroyCarDealershipVehicle(GetCarDealershipId(vehid), GetCarDealershipVehicleId(vehid));
format(string, sizeof(string), " Car Dealership Vehicle destroyed with ID %d.", vehid);
SendClientMessage(playerid, COLOR_GRAD1, string);
}
if(strcmp(cmd, "/createdealership", true) == 0)
{
if (PlayerInfo[playerid][pAdmin] < 5)
{
SendClientMessage(playerid, COLOR_GREY, " You are not allowed to use this command.");
return 1;
}
tmp = strtok(cmdtext,idx);
new radius;
if (!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /createdealership [price] [radius] [message]");
return 1;
}
new price = strval(tmp);
tmp = strtok(cmdtext, idx);
if (!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /createdealership [price] [radius] [message]");
return 1;
}
radius = strval(tmp);
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /createdealership [price] [radius] [message]");
return 1;
}
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid,X,Y,Z);
new dealershipid = CreateCarDealership(X, Y, Z, radius, price, result);
if(dealershipid == -1)
{
SendClientMessage(playerid, COLOR_GREY, "ERROR: Car Dealerships limit reached.");
}
else
{
format(string, sizeof(string), " Car Dealership created with ID %d.", dealershipid);
SendClientMessage(playerid, COLOR_GRAD1, string);
}
}
if(strcmp(cmd, "/destroydealership", true) == 0)
{
if (PlayerInfo[playerid][pAdmin] < 5)
{
SendClientMessage(playerid, COLOR_GREY, " You are not allowed to use this command.");
return 1;
}
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);
SendClientMessage(playerid, COLOR_GRAD1, string);
return 1;
}
}
new dealershipid;
tmp = strtok(cmdtext, idx);
if (!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /destroydealership [dealershipid]");
return 1;
}
dealershipid = strval(tmp);
if(dealershipid > MAX_CARDEALERSHIPS) return 1;
if(dealershipid < 0) return 1;
DestroyCarDealership(dealershipid);
format(string, sizeof(string), " Car Dealership destroyed with ID %d.", dealershipid);
SendClientMessage(playerid, COLOR_GRAD1, string);
}
if(strcmp(cmd, "/vehid", true) == 0)
{
if(IsPlayerInAnyVehicle(playerid))
{
format(string, sizeof(string), "* Vehicle Name: %s | Vehicle ID: %d.",GetVehicleName(idcar), idcar);
SendClientMessage(playerid, COLOR_GREY, string);
}
return 1;
}
if(strcmp(cmd, "/createvehicle", true) == 0)
{
if (PlayerInfo[playerid][pAdmin] < 5)
{
SendClientMessage(playerid, COLOR_GREY, " You are not allowed to use this command.");
return 1;
}
tmp = strtok(cmdtext,idx);
new modelid;
if (!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /createvehicle [playerid/partOfName] [modelid] [color 1] [color 2]");
return 1;
}
giveplayerid = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
if (!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /createvehicle [playerid/partOfName] [modelid] [color 1] [color 2]");
return 1;
}
modelid = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /createvehicle [playerid/partOfName] [modelid] [color 1] [color 2]");
return 1;
}
new color1;
color1 = strval(tmp);
if(color1 < 0 || color1 > 126) { SendClientMessage(playerid, COLOR_GREY, " Color Number can't be below 0 or above 126 !"); return 1; }
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /createvehicle [playerid/partOfName] [modelid] [color 1] [color 2]");
return 1;
}
new color2;
color2 = strval(tmp);
if(color2 < 0 || color2 > 126) { SendClientMessage(playerid, COLOR_GREY, " Color Number can't be below 0 or above 126 !"); return 1; }
if(modelid < 400 || modelid > 611) { SendClientMessage(playerid, COLOR_GREY, " Vehicle Number can't be below 400 or above 611 !"); return 1; }
new playervehicleid = GetPlayerFreeVehicleId(giveplayerid);
if(playervehicleid == -1) return SendClientMessage(playerid, COLOR_GREY, "ERROR: That player can't have more cars.");
new Float:X,Float:Y,Float:Z;
GetPlayerPos(giveplayerid,X,Y,Z);
new Float:Angle;
GetPlayerFacingAngle(giveplayerid,Angle);
new car = CreatePlayerVehicle(giveplayerid, playervehicleid, modelid, X, Y, Z, Angle, color1, color2);
if(car == INVALID_PLAYER_VEHICLE_ID)
{
SendClientMessage(playerid, COLOR_GREY, "ERROR: Something went wrong and the car didn't got created.");
}
else
{
format(string, sizeof(string), " Vehicle successfully created with ID %d.", car);
SendClientMessage(playerid, COLOR_GRAD1, string);
}
}
if(strcmp(cmd, "/destroyvehicle", true) == 0)
{
if (PlayerInfo[playerid][pAdmin] < 4)
{
SendClientMessage(playerid, COLOR_GREY, " You are not allowed to use this command.");
return 1;
}
tmp = strtok(cmdtext,idx);
new vehicleid;
if (!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /destroyvehicle [playerid/partOfName] [vehicleid]");
return 1;
}
giveplayerid = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
if (!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /destroyvehicle [playerid/partOfName] [vehicleid]");
return 1;
}
vehicleid = strval(tmp);
new playervehicleid = GetPlayerVehicle(giveplayerid, vehicleid);
if(playervehicleid == -1) return SendClientMessage(playerid, COLOR_GREY, "ERROR: That player doesn't own that vehicle.");
DestroyPlayerVehicle(giveplayerid, playervehicleid);
}
if (strcmp(cmdtext, "/map", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if (PlayerToPoint(3, playerid, 1737.1313,-2238.4797,13.5439))
{
ShowPlayerDialog(playerid, MAPMENU, DIALOG_STYLE_LIST, "LS Map","Gym\nSAST\nLSPD\nAll Saints\nStadium\nPrison\nBank\nCityhall\n24-7\nLicenses Department\nPaintball\nChop Shop", "Mark", "Cancel");
LSMap[playerid] = 1;
}
}
return 1;
}