I have a command but when someone uses it, it crashes the server.
pawn Код:
CMD:getpizza(playerid, params[])
{
if(PlayerInfo[playerid][pJob] != 21 && PlayerInfo[playerid][pJob2] != 21)
{
SCM(playerid,COLOR_GREY,"You're not a Pizza Boy!");
return 1;
}
new vehicleid = GetPlayerVehicleID(playerid);
if(!(IsAPizzaCar(vehicleid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER))
{
SCM(playerid,COLOR_GREY,"You need to be driving a pizzaboy found at the side of the Pizza Stack!");
return 1;
}
if(!(GetPlayerSkin(playerid) == 155))
{
SCM(playerid,COLOR_GREY,"You need to be in the Pizza Stack uniform!");
return 1;
}
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
if(!IsPlayerInRangeOfPoint(playerid, 3.0, 2098.9658,-1806.6515,13.5550))
{
SCM(playerid,COLOR_GREY,"You're not at the Pizza Stack pickup!");
return 1;
}
if(GetPVarInt(playerid, "Pizza") > 0)
{
SCM(playerid, COLOR_GREY, "You're already delivering pizzas!");
return 1;
}
/*new rand = random(MAX_HOUSES -1);
while(!(HouseInfo[rand][hExteriorZ] < 150.0 && HouseInfo[rand][hExteriorX] > 17.59 && HouseInfo[rand][hExteriorX] < 3004.64 && HouseInfo[rand][hExteriorY] < -805.45 && HouseInfo[rand][hExteriorY] > -2736.25))
{
rand++;
if(rand == MAX_HOUSES) {
rand = 1;
}
//printf("%d", rand);
}*/
/* new rand = random(165);
while(!(HouseInfo[rand][hExteriorZ] < 150.0 && HouseInfo[rand][hExteriorX] > 17.59 && HouseInfo[rand][hExteriorX] < 3004.64 && HouseInfo[rand][hExteriorY] < -805.45 && HouseInfo[rand][hExteriorY] > -2736.25))
{
rand++;
if(rand == 165) {
rand = 1;
}
//printf("%d", rand);
}
SetPVarInt(playerid, "tpPizzaTimer", floatround((GetPizzaDistance(rand) / 60), floatround_round));
SetPVarInt(playerid, "pizzaTotal", floatround((GetPizzaDistance(rand) / 10), floatround_round));
SetPVarInt(playerid, "pizzaTimer", GetPVarInt(playerid, "pizzaTotal"));
SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_TPPIZZARUNTIMER);
SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_PIZZATIMER);
new szMessage[128];
if(HouseInfo[rand][hOwned] == 0)
{
format(szMessage, sizeof(szMessage), "You have picked up a pizza for someone. You have %d seconds to deliver it!", GetPVarInt(playerid, "pizzaTotal"));
}
else
{
format(szMessage, sizeof(szMessage), "You have picked up a pizza for %s. You have %d seconds to deliver it!", HouseInfo[rand][hOwner], GetPVarInt(playerid, "pizzaTotal"));
}
SCM(playerid, COLOR_WHITE, szMessage);
SetPVarInt(playerid, "Pizza", rand);
PizzaBar[playerid] = CreateProgressBar(258.00, 137.00, 131.50, 3.19, COLOR_GREEN, 100.0);
SetProgressBarValue(PizzaBar[playerid], 100.0);
ShowProgressBarForPlayer(playerid, PizzaBar[playerid]);
SetPlayerCheckpoint(playerid, HouseInfo[rand][hExteriorX], HouseInfo[rand][hExteriorY], HouseInfo[rand][hExteriorZ], 5);
return 1;
}*/
}
Your script crashed because there are no houses in your server or no houses near the getpizza point.
Create houses near the getpiza place. It will work fine