24.01.2014, 12:33
I have some problem with my server when i buy a car from dealership then the server like freezing for like 30 sec i think this code have some issuse mabye you guys can help me out?
pawn Код:
}
case 4: // Purchase
{
new pass = 0;
switch(NormalCar[GetPVarInt(playerid, "NormalCarID")][carID])
{
case 462, 468, 481, 509, 510: pass = 1;
}
if(pass == 0 && GetPVarInt(playerid, "DriveLic") == 0) return SendClientMessage(playerid, COLOR_WHITE, "You need a license to purchase this type of vehicle."), ShowPlayerDialog(playerid,58,DIALOG_STYLE_LIST,"Dealership","Select Vehicle\nGo Back\nColor 1\nColor 2\nPurchase","Select", "Exit");
new found=0;
for(new i = 0; i < sizeof(CarInfo); i++)
{
if(CarInfo[i][cOwned] == 0)
{
found=1;
new price = 0,string[128];
if(GetPVarInt(playerid, "CarTicket") > 0) { price = 0; SetPVarInt(playerid, "DonateCar", 1); }
else { price = NormalCar[GetPVarInt(playerid, "NormalCarID")][carprice]; }
if(GetPlayerMoneyEx(playerid) >= price)
{
if(GetPVarInt(playerid, "ConnectTime") >= NormalCar[GetPVarInt(playerid, "NormalCarID")][carlevel])
{
if(NormalCar[GetPVarInt(playerid, "NormalCarID")][carQ] >= 1)
{
if(GetPVarInt(playerid, "CarKey1") == SCRIPT_CARS || GetPVarInt(playerid, "CarKey2") == SCRIPT_CARS || GetPVarInt(playerid, "CarKey3") == SCRIPT_CARS)
{
SetPlayerPos(playerid,2130.7195,-1147.0983,24.3918);
SetPlayerVirtualWorld(playerid,0);
SetCameraBehindPlayer(playerid);
TogglePlayerControllableEx(playerid,true);
DestroyVehicle(GetPVarInt(playerid, "NormalVeh"));
DeletePVar(playerid,"BuyingCar");
if(GetPVarInt(playerid, "CarKey1") == SCRIPT_CARS) SetPVarInt(playerid, "CarKey1", i);
else if(GetPVarInt(playerid, "CarKey2") == SCRIPT_CARS) SetPVarInt(playerid, "CarKey2", i);
else if(GetPVarInt(playerid, "CarKey3") == SCRIPT_CARS) SetPVarInt(playerid, "CarKey3", i);
format(string, sizeof(string), "You have bought a %s for $%d.",NormalCar[GetPVarInt(playerid, "NormalCarID")][carname],price);
SendClientMessage(playerid,COLOR_WHITE,string);
SendClientMessage(playerid,COLOR_WHITE,"Use (/v) for help commands on ownable vehicles.");
GivePlayerMoneyEx(playerid,-price);
GovernmentShare += price;
CarInfo[i][cOwned] = 1;
CarInfo[i][cModel] = NormalCar[GetPVarInt(playerid, "NormalCarID")][carID];
CarInfo[i][cValue] = NormalCar[GetPVarInt(playerid, "NormalCarID")][carprice];
if(NormalCar[GetPVarInt(playerid, "NormalCarID")][carID] != 481) NormalCar[GetPVarInt(playerid, "NormalCarID")][carQ]--;
CarInfo[i][cX] = 2130.7195;
CarInfo[i][cY] = -1147.0983;
CarInfo[i][cZ] = 24.3918;
CarInfo[i][cAngle] = 0.0;
CarInfo[i][cFuel] = 100;
CarInfo[i][cHealth] = 1000.0;
CarInfo[i][cDonate]=0;
CarInfo[i][cPlateV]=0;
CarInfo[i][cGPS]=0;
CarInfo[i][cTime]=0;
CarInfo[i][cBomb]=0;
CarInfo[i][cSeatWeed]=0;
CarInfo[i][cSeatCrack]=0;
CarInfo[i][cSeatCocaine]=0;
CarInfo[i][cSeatGun]=0;
CarInfo[i][cSeatAmmo]=0;
CarInfo[i][cDelay]=0;
CarInfo[i][cIns]=0;
CarInfo[i][cColorOne]=GetPVarInt(playerid, "NormalColor1");
CarInfo[i][cColorTwo]=GetPVarInt(playerid, "NormalColor2");
strmid(CarInfo[i][cPlate], "NONE", 0, strlen("NONE"), 255);
if(GetPVarInt(playerid, "DonateCar") == 1)
{
CarInfo[i][cValue] = 0;
CarInfo[i][cDonate] = 1;
SetPVarInt(playerid, "CarTicket", GetPVarInt(playerid, "CarTicket")-1);
DeletePVar(playerid,"DonateCar");
}
for(new m = 0; m < 10; m++) { CarInfo[i][cMod][m] = 0; }
for(new i2 = 0; i2 < 5; i2++)
{
CarInfo[i][cTWeapon][i2]=0;
CarInfo[i][cTAmmo][i2]=0;
}
CarInfo[i][cTWeed]=0;
CarInfo[i][cTCocaine]=0;
CarInfo[i][cTCrack]=0;
CarInfo[i][cTArmour]=0.0;
CarInfo[i][cGasCan]=0;
DeletePVar(playerid,"NormalCarID");
DeletePVar(playerid,"NormalVeh");
DeletePVar(playerid,"NormalColor1");
DeletePVar(playerid,"NormalColor2");
strmid(CarInfo[i][cOwner], PlayerName(playerid), 0, strlen(PlayerName(playerid)), 255);
OnPlayerDataSave(playerid);
SaveCars();
SaveCars2();
SaveNormalCars();
//allRemoteFunction("GiveAchievement", "iii", playerid, 3, 1);
return 1;