Time freeze using CMDS [vehicle]
#1

Hello guys ,right now i`m improving my dynamic dealership that i made almost from scrathch.
I made a basic comand [ /buyinfernus] to see if its working.
And i also made /v park /v color etc.

All of them work,except 1 thing: after i use one of those cmds[/buyinfernus , /v park , /v color etc] the time freezes for ~11 seconds,and then everything works fine.
I dont know why after one of those cmds ,the time stopps for 11 seconds.
I accept any tips,thanks in advance.


/buyinfernus cmd

PHP код:
  // comanda buy infernus//
        
if(strcmp(cmd"/buyinfernus"true) == 0)
    {
    
    
        if(
PlayerInfo[playerid][pPcarkey] == -1) { }
        else if(
PlayerInfo[playerid][pPcarkey2] == -1) { }
        else if(
PlayerInfo[playerid][pPcarkey3] == -1) { }
        else { 
SendClientMessage(playeridCOLOR_GREY"* Detii 3 masini!"); return 1; }
        if(
PlayerInfo[playerid][pLevel] >= )
         {
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOR_WHITE"{00A1FF}USAGE:{C0C0C0} /buyinfernus [color1] [color2] ");
                return 
1;
            }
        
//    new car;
        //    car = strval(tmp);
        //    if(car < 411 || car > 411) { SendClientMessage(playerid, COLOR_WHITE, "{0950F7}*Aceasta este comanda de a cumpara infernus !"); return 1; }
        //    tmp = strtok(cmdtext, idx);
    //    if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "{00A1FF}USAGE:{C0C0C0} /buyinfernus"); return 1; }
         
            
new color1;
            
color1 strval(tmp);
            if(
color1 || color1 126) { SendClientMessage(playeridCOLOR_WHITE"{0950F7}* Color Number can't be below 0 or above 126 !"); return 1; }
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp)) { SendClientMessage(playeridCOLOR_WHITE"{00A1FF}USAGE:{C0C0C0} /acreatecar [carid] [color1] [color2] [price]"); return 1; }
            new 
color2;
            
color2 strval(tmp);
            if(
color2 || color2 126) { SendClientMessage(playeridCOLOR_WHITE"{0950F7}* Color Number can't be below 0 or above 126 !"); return 1; }
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp)) { SendClientMessage(playeridCOLOR_WHITE"{00A1FF}USAGE:{C0C0C0} /acreatecar [carid] [color1] [color2] [price]"); return 1; }
            new 
Float:X,Float:Y,Float:ZGetPlayerPos(playeridX,Y,Z);
            new 
thiscar CreateVehicle(411,X,Y,Z,1,color1,color2,99999999);
               if(
PlayerInfo[playerid][pPcarkey] == -1) { PlayerInfo[playerid][pPcarkey] = thiscar; }
              else if(
PlayerInfo[playerid][pPcarkey2] == -1) { PlayerInfo[playerid][pPcarkey2] = thiscar; }
               else if(
PlayerInfo[playerid][pPcarkey3] == -1) { PlayerInfo[playerid][pPcarkey3] = thiscar; }
            else { return 
1; }
            
          
//  new value = strval(tmp);
            
CarInfo[thiscar][cModel] = 411CarInfo[thiscar][cColorOne] = color1CarInfo[thiscar][cColorTwo] = color2;
               
CarInfo[thiscar][cLocationx] = XCarInfo[thiscar][cLocationy] = YCarInfo[thiscar][cLocationz] = ZCarInfo[thiscar][cAngle] = 1;
            
CarInfo[thiscar][paintjob] = -1LoadComponents(thiscar); PutPlayerInVehicle(playerid,thiscar,0);
            
CarInfo[thiscar][cOwned] = 1;
            
GetPlayerName(playeridsendernamesizeof(sendername));
            
strmid(CarInfo[thiscar][cOwner], sendername0strlen(sendername), 999);
            
GivePlayerMoney(playerid,-150000);
            
//Delete3DTextLabel(TextUpCar[idcar]);
              
OnCarUpdate(); SavePlayerData(playerid);
            
PlayerPlaySound(playerid10520.00.00.0);
            
GameTextForPlayer(playerid"~w~Felicitari~n~ai platit 150k pentru infernus !"50003);
            
TogglePlayerControllable(playerid1);
          return 
1;
          }
    } 
And the v color/park etc cmds:

PHP код:
//==========================[/v(ehicle)]========================================
    
if(strcmp(cmd"/v"true) == || strcmp(cmd"/vehicle"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            new 
x_nr[64];
            
x_nr strtok(cmdtextidx);
            if(!
strlen(x_nr))
            {
                
SendClientMessage(playeridCOLOR_WHITE"____________[Personal Vehicle Help]____________");
                
SendClientMessage(playeridCOLOR_WHITE"** {1AFF00}(/v)ehicle {09DFF7}[name]");
                
SendClientMessage(playeridCOLOR_WHITE"**buy, park, color, tow(1-3), fix(1-3), model");
                return 
1;
            }
            if(
strcmp(x_nr,"park",true) == 0)
            {
                new 
Float:x,Float:y,Float:z;
                new 
Float:a;
                new 
carid;
                new 
getcarid GetPlayerVehicleID(playerid);
                if(
GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { carid PlayerInfo[playerid][pPcarkey]; }
                else if(
GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { carid PlayerInfo[playerid][pPcarkey2]; }
                else if(
GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey3]) { carid PlayerInfo[playerid][pPcarkey3]; }
                else { return 
1; }
                
GetPlayerName(playeridplayernamesizeof(playername));
                
GetVehiclePos(caridxyz);
                
GetVehicleZAngle(carida);
                if(
IsPlayerInVehicle(playerid,carid) && CarInfo[carid][cOwned] == 1)
                {
                       if(
PlayerInfo[playerid][pPcarkey] == -&& PlayerInfo[playerid][pPcarkey2] == -&& PlayerInfo[playerid][pPcarkey3] == -1)
                    {
                        
SendClientMessage(playeridCOLOR_GREY"N ai o masina personala.");
                        return 
1;
                    }
                       if(
getcarid == carid)
                    {
                        new 
Float:CarHPFloat:OldCarHP; new panels,doors,lights,tires;
                        
CarInfo[carid][cLocationx] = x;
                        
CarInfo[carid][cLocationy] = y;
                        
CarInfo[carid][cLocationz] = z;
                        
CarInfo[carid][cAngle] = a;
                        
GetVehicleDamageStatus(carid,panels,doors,lights,tires);
                        
GetVehicleHealth(caridCarHP); OldCarHP CarHP;
                        
OnCarUpdate(); DestroyVehicle(carid);
                        
CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],60000);
//                        format(TextCar, sizeof(TextCar), "{EE1111}Owner: {0099FF}• %s •", CarInfo[carid][cOwner]);
//                       Update3DTextLabelText(TextUpCar[carid], 0x33AAFFFF, TextCar);
                        
LoadComponents(carid);
                        
SendClientMessage(playeridCOLOR_BLUE"* Noua pozitie a fost salvata!");
                         
SetVehicleHealth(caridOldCarHP);
                        
UpdateVehicleDamageStatus(caridpanelsdoorslightstires);
                        return 
1;
                       }
                }
            }
          
/*  else if(strcmp(x_nr,"buy",true) == 0)
            {
                if(IsAnOwnableCar(idcar))
                {
                    if(PlayerInfo[playerid][pPcarkey] == -1) { }
                    else if(PlayerInfo[playerid][pPcarkey2] == -1) { }
                    else if(PlayerInfo[playerid][pPcarkey3] == -1) { }
                    else { SendClientMessage(playerid, COLOR_GREY, "* Detii 3 masini!"); return 1; }
                    if(CarInfo[idcar][cOwned]==1)
                    {
                        SendClientMessage(playerid, COLOR_GREY, "Someone already owns this car.");
                        return 1;
                    }
                    if(GetPlayerMoney(playerid) >= CarInfo[idcar][cValue])
                    {
                        if(PlayerInfo[playerid][pPcarkey] == -1) { PlayerInfo[playerid][pPcarkey] = idcar; }
                        else if(PlayerInfo[playerid][pPcarkey2] == -1) { PlayerInfo[playerid][pPcarkey2] = idcar; }
                        else if(PlayerInfo[playerid][pPcarkey3] == -1) { PlayerInfo[playerid][pPcarkey3] = idcar; }
                        else { return 1; }
                        CarInfo[idcar][cOwned] = 1;
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        strmid(CarInfo[idcar][cOwner], sendername, 0, strlen(sendername), 999);
                        GivePlayerMoney(playerid,-CarInfo[idcar][cValue]);
                        Delete3DTextLabel(TextUpCar[idcar]);
                        //format(TextCar, sizeof(TextCar), "{EE1111}Owner: {0099FF}• %s •", CarInfo[idcar][cOwner]);
                        //TextUpCar[idcar] = Create3DTextLabel(TextCar, 0x33AAFFFF, 0.0, 0.0, 0.0, 25, 0, 1);
                        //Attach3DTextLabelToVehicle(TextUpCar[idcar], idcar, 0.0, 0.0, 0.1);
                        OnCarUpdate(); SavePlayerData(playerid);
                        PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                        GameTextForPlayer(playerid, "~w~Felicitari~n~Nu uita sa o parchezi cu /v park !", 5000, 3);
                        TogglePlayerControllable(playerid, 1);
                        return 1;
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GREY, " You don't have enough cash with you!");
                        return 1;
                    }
                }
            } */
            
else if(strcmp(x_nr,"color",true) == 0)
            {
                if(
PlayerInfo[playerid][pPcarkey] == -&& PlayerInfo[playerid][pPcarkey2] == -&& PlayerInfo[playerid][pPcarkey3] == -1)
                {
                    
SendClientMessage(playeridCOLOR_GREY,"  You don't have a Vehicle to respray.");
                    return 
1;
                }
                if(
GetPlayerMoney(playerid) < 1000)
                {
                    
SendClientMessage(playeridCOLOR_GREY,"  You don't have enough money for vehicle respray.");
                    return 
1;
                }
                
tmp strtok(cmdtextidx);
                if(!
strlen(tmp))
                {
                    
SendClientMessage(playeridCOLOR_WHITE"USAGE: /v color [ColorOneID] [ColorTwoID]");
                    return 
1;
                }
                new 
color1;
                
color1 strval(tmp);
                if(
color1 && color1 126)
                {
                    
SendClientMessage(playeridCOLOR_GREY" Wrong color id!");
                    return 
1;
                }
                
tmp strtok(cmdtextidx);
                if(!
strlen(tmp))
                {
                    
SendClientMessage(playeridCOLOR_WHITE"USAGE: /v color [ColorOneID] [ColorTwoID]");
                    return 
1;
                }
                new 
color2;
                
color2 strval(tmp);
                if(
color2 && color2 126)
                {
                    
SendClientMessage(playeridCOLOR_GREY" Wrong color id!");
                    return 
1;
                }
                if(
GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { vehid PlayerInfo[playerid][pPcarkey]; }
                else if(
GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { vehid PlayerInfo[playerid][pPcarkey2]; }
                else if(
GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey3]) { vehid PlayerInfo[playerid][pPcarkey3]; }
                else { return 
1; }
                if(
IsPlayerInVehicle(playeridvehid))
                {
                    new 
Float:CarHPFloat:OldCarHP;
                    new 
panelsdoorslightstires;
                    
GetVehicleDamageStatus(vehidpanelsdoorslightstires);
                    
GetVehicleHealth(vehidCarHP); OldCarHP CarHP;
                     
CarInfo[vehid][cColorOne] = color1;
                    
CarInfo[vehid][cColorTwo] = color2;
                    
GivePlayerMoney(playerid, -1000);
                    
GameTextForPlayer(playerid"~w~Masina Personala~n~~g~Revopsita cu succes~n~~r~$-100"50001);
                    
ChangeVehicleColor(vehidcolor1color2);
                    
SetVehicleToRespawn(vehid);
                    
SetVehicleHealth(vehidOldCarHP);
                    
UpdateVehicleDamageStatus(vehidpanelsdoorslightstires);
                    
PlayerPlaySound(playerid10520.00.00.0);
                    
OnCarUpdate();
                    return 
1;
                }
                else
                {
                    
SendClientMessage(playeridCOLOR_GREY," You are not in your Personal car.");
                    return 
1;
                }
            }
            
/*else if(strcmp(x_nr,"locate1",true) == 0)
            {
                 if(!IsPlayerConnected(playerid)) { return 1; }
                new Float:x,Float:y,Float:z;
                new car = PlayerInfo[playerid][pPcarkey];
                if(PlayerInfo[playerid][pPcarkey]==-1) { GameTextForPlayer(playerid, "~w~Nu ai o masina pentru a putea fi localizata", 2500, 3); return 1; }
                SendClientMessage(playerid,COLOR_WHITE,"Locatia masinii a fost gasita.");
                GetVehiclePos(car, x, y, z);
                SetPlayerCheckpoint(playerid, x, y, z, 6);
                return 1;
            }
            else if(strcmp(x_nr,"locate2",true) == 0)
            {
                 if(!IsPlayerConnected(playerid)) { return 1; }
                new Float:x,Float:y,Float:z;
                new car = PlayerInfo[playerid][pPcarkey2];
                if(PlayerInfo[playerid][pPcarkey2]==-1) { GameTextForPlayer(playerid, "~w~Nu ai o masina pentru a putea fi localizata", 2500, 3); return 1; }
                SendClientMessage(playerid,COLOR_WHITE,"Locatia masinii a fost gasita.");
                GetVehiclePos(car, x, y, z);
                SetPlayerCheckpoint(playerid, x, y, z, 6);
                return 1;
            }
            else if(strcmp(x_nr,"locate3",true) == 0)
            {
                 if(!IsPlayerConnected(playerid)) { return 1; }
                new Float:x,Float:y,Float:z;
                new car = PlayerInfo[playerid][pPcarkey3];
                if(PlayerInfo[playerid][pPcarkey3]==-1) { GameTextForPlayer(playerid, "~w~Nu ai o masina pentru a putea fi localizata", 2500, 3); return 1; }
                SendClientMessage(playerid,COLOR_WHITE,"Locatia masinii a fost gasita.");
                GetVehiclePos(car, x, y, z);
                SetPlayerCheckpoint(playerid, x, y, z, 6);
                return 1;
            }*/
            
else if(strcmp(x_nr,"tow1",true) == 0)
            {
                if(
IsPlayerConnected(playerid))
                {
                    new 
Float:CarHPFloat:OldCarHP;
                    new 
panels,doors,lights,tires;
                    new 
car PlayerInfo[playerid][pPcarkey];
                    
GetPlayerName(playeridplayernamesizeof(playername));
                    if (
car != -&& strcmp(playernameCarInfo[PlayerInfo[playerid][pPcarkey]][cOwner], true) == 0)
                    {
                        
GetVehicleDamageStatus(car,panels,doors,lights,tires);
                        
GetVehicleHealth(carCarHP); OldCarHP CarHP;
                        
GameTextForPlayer(playerid"~w~Masina personala~n~~g~Tractata cu succes~n~~r~$-1.500"50001);
                        
GivePlayerMoney(playerid,-1500);
                        
SetVehicleToRespawn(car);
                        
SetVehicleHealth(carOldCarHP);
                        
UpdateVehicleDamageStatus(carpanelsdoorslightstires);
                        
PlayerPlaySound(playerid10520.00.00.0);
                    }
                    else
                    {
                        
GameTextForPlayer(playerid"~w~Nu detii o masina personala."50001);
                    }
                }
            }
            else if(
strcmp(x_nr,"tow2",true) == 0)
            {
                if(
IsPlayerConnected(playerid))
                {
                    new 
Float:CarHPFloat:OldCarHP;
                    new 
panels,doors,lights,tires;
                    new 
car PlayerInfo[playerid][pPcarkey2];
                    
GetPlayerName(playeridplayernamesizeof(playername));
                    if (
car != -&& strcmp(playernameCarInfo[PlayerInfo[playerid][pPcarkey2]][cOwner], true) == 0)
                    {
                        
GetVehicleDamageStatus(car,panels,doors,lights,tires);
                        
GetVehicleHealth(carCarHP); OldCarHP CarHP;
                        
GameTextForPlayer(playerid"~w~Masina personala~n~~g~Tractata cu succes~n~~r~$-1.500"50001);
                        
GivePlayerMoney(playerid,-1500);
                        
SetVehicleToRespawn(car);
                        
SetVehicleHealth(carOldCarHP);
                        
UpdateVehicleDamageStatus(carpanelsdoorslightstires);
                        
PlayerPlaySound(playerid10520.00.00.0);
                    }
                    else
                    {
                        
GameTextForPlayer(playerid"~w~Nu detii o masina personala."50001);
                    }
                }
            }
            else if(
strcmp(x_nr,"tow3",true) == 0)
            {
                if(
IsPlayerConnected(playerid))
                {
                    new 
Float:CarHPFloat:OldCarHP;
                    new 
panels,doors,lights,tires;
                    new 
car PlayerInfo[playerid][pPcarkey3];
                    
GetPlayerName(playeridplayernamesizeof(playername));
                    if (
car != -&& strcmp(playernameCarInfo[PlayerInfo[playerid][pPcarkey3]][cOwner], true) == 0)
                    {
                        
GetVehicleDamageStatus(car,panels,doors,lights,tires);
                        
GetVehicleHealth(carCarHP); OldCarHP CarHP;
                        
GameTextForPlayer(playerid"~w~Masina personala~n~~g~Tractata cu succes~n~~r~$-1.500"50001);
                        
GivePlayerMoney(playerid,-1500);
                        
SetVehicleToRespawn(car);
                        
SetVehicleHealth(carOldCarHP);
                        
UpdateVehicleDamageStatus(carpanelsdoorslightstires);
                        
PlayerPlaySound(playerid10520.00.00.0);
                    }
                    else
                    {
                        
GameTextForPlayer(playerid"~w~Nu detii o masina personala."50001);
                    }
                }
            }
            else if(
strcmp(x_nr,"fix1",true) == 0)
            {
                if(
IsPlayerConnected(playerid))
                {
                    new 
car PlayerInfo[playerid][pPcarkey];
                    
GetPlayerName(playeridplayernamesizeof(playername));
                    if (
car != -&& strcmp(playernameCarInfo[PlayerInfo[playerid][pPcarkey]][cOwner], true) == 0)
                    {
                        
GameTextForPlayer(playerid"~w~Masina personala~n~~g~Reparata cu succes~n~~r~$-2.500"50001);
                        
GivePlayerMoney(playerid,-2500);
                        
SetVehicleToRespawn(car);
                        
PlayerPlaySound(playerid10520.00.00.0);
                    }
                    else
                    {
                        
GameTextForPlayer(playerid"~w~Nu detii o masina personala."50001);
                    }
                }
            }
            else if(
strcmp(x_nr,"fix2",true) == 0)
            {
                if(
IsPlayerConnected(playerid))
                {
                    new 
car PlayerInfo[playerid][pPcarkey2];
                    
GetPlayerName(playeridplayernamesizeof(playername));
                    if (
car != -&& strcmp(playernameCarInfo[PlayerInfo[playerid][pPcarkey2]][cOwner], true) == 0)
                    {
                        
GameTextForPlayer(playerid"~w~Masina personala~n~~g~Reparata cu succes~n~~r~$-2.500"50001);
                        
GivePlayerMoney(playerid,-2500);
                        
SetVehicleToRespawn(car);
                        
PlayerPlaySound(playerid10520.00.00.0);
                    }
                    else
                    {
                        
GameTextForPlayer(playerid"~w~Nu detii o masina personala."50001);
                    }
                }
            }
            else if(
strcmp(x_nr,"fix3",true) == 0)
            {
                if(
IsPlayerConnected(playerid))
                {
                    new 
car PlayerInfo[playerid][pPcarkey3];
                    
GetPlayerName(playeridplayernamesizeof(playername));
                    if (
car != -&& strcmp(playernameCarInfo[PlayerInfo[playerid][pPcarkey3]][cOwner], true) == 0)
                    {
                        
GameTextForPlayer(playerid"~w~Masina personala~n~~g~Reparata cu succes~n~~r~$-2.500"50001);
                        
GivePlayerMoney(playerid,-2500);
                        
SetVehicleToRespawn(car);
                        
PlayerPlaySound(playerid10520.00.00.0);
                    }
                    else
                    {
                        
GameTextForPlayer(playerid"~w~Nu detii o masina personala."50001);
                    }
                }
            }
            else if(
strcmp(x_nr,"x2x1x4x4x1",true) == 0)
            {
                new 
Float:x,Float:y,Float:z;
                new 
carid;
                new 
Float:a;
                new 
Float:CarHPFloat:OldCarHP;
                new 
panels,doors,lights,tires;
                
carid GetPlayerVehicleID(playerid);
                
GetVehiclePos(caridxyz);
                
GetVehicleZAngle(carida);
                if(
IsPlayerInVehicle(playerid,carid))
                {
                    if(
PlayerInfo[playerid][pDonateRank] < 3)
                    {
                        
SCM(playeridCOLOR_GREY"* Trebuie sa ai cont EXTRA VIP pentru acces la /v model!");
                        return 
1;
                    }
                    if(
GetPlayerMoney(playerid) < 5000)
                    {
                    
SendClientMessage(playeridCOLOR_GREY,"Nu ai destui bani.");
                    return 
1;
                    }
                    
tmp strtok(cmdtextidx);
                    if(!
strlen(tmp))
                    {
                        
SCM(playeridCOLOR_GREY"USAGE: x");
                        return 
1;
                    }
                    new 
model;
                    
model strval(tmp);
                    if(
model 400 || model 611)
                    {
                    
SCM(playeridCOLOR_GREY"* x");
                    return 
1;
                    }
                    else
                    {
                    
//new tittle[128];
                    //new carkey = PlayerInfo[playerid][pPcarkey];
                    //format(tittle,128,"%s", CarInfo[carkey][cModel]);
                    //else
                    //{
                    
CarInfo[carid][cModel] = model;
                     
CarInfo[carid][cLocationx] = x;
                     
CarInfo[carid][cLocationy] = y;
                     
CarInfo[carid][cLocationz] = z;
                     
CarInfo[carid][cAngle] = a;
                     
//format(string, sizeof(string), "~n~ You changed Car's Model~n~");
                     
GetVehicleDamageStatus(carid,panels,doors,lights,tires);
                    
GetVehicleHealth(caridCarHP); OldCarHP CarHP;
                    
OnCarUpdate(); DestroyVehicle(carid);
                    
CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],60000);
                    
LoadComponents(carid);
                    
GivePlayerMoney(playerid, -5000);
                    
SendClientMessage(playeridCOLOR_BLUE"* Schimbarea modelului te-a costat $5.000!");
                     
//format(string, sizeof(string), "~n~ You changed Car's Model~n~");
                     
SetVehicleHealth(caridOldCarHP);
                    
UpdateVehicleDamageStatus(caridpanelsdoorslightstires);
                    
format(CarInfo[carid][cDescription], 32"%s",vehName[model-400]);
                    return 
1;
                    }
                
/*else
                {
                SCM(playerid, COLOR_GREY, "* Trebuie sa fi in masina pentru a utiliza comanda!");
                return 1;
                }*/
               
}
               return 
1;
            }
            else
            {
                
SendClientMessage(playeridCOLOR_WHITE"____________[Personal Vehicle Help]____________");
                
SendClientMessage(playeridCOLOR_WHITE"** {1AFF00}(/v)ehicle {09DFF7}[name]");
                
SendClientMessage(playeridCOLOR_WHITE"**buy, park, color, tow(1-3), fix(1-3), model");
                return 
1;
            }
           }
        return 
1;
    } 
REMIND: everything works fine after those 11 seconds[not just for me,for the hole server] but i want to remove this time freeze/bug/stop .Thanks in advance.
Reply
#2

What do you mean by time freeze?

As in the server freezes for some time? or do you mean you made a textdraw with server time and it stopped updating?

if its the server freezing then you are calling an update function which is hanging for 11 seconds causing any other server actions/processes to wait. Remember SA-MP is single threaded, meaning if you had:

Код:
public OnGameModeInit()
{
       FunctionOne();
       FunctionTwo();
       return 1;
}

public FunctionOne()
{
        for(;;) { print("Never Ending Loop"); }
        return 1;
}

public FunctionTwo()
{
      print("Function Two Called");
      return 1;
}
Function Two will never get called as function one will never complete its process. So you need to check your script for endless or wasted for loops.

- Think clearly about what your for loops are being used for.
- Also if you can I would suggest using something other then 'strcmp' for commands, try (ZCMD, DCMD, etc)
Reply
#3

I searched but the problem is just at CMDS with vehicles involved such as /buyinfernus , /v color , /vpark so i think its from one of those cmds.
yes the server freezes for 11 seconds and then it come`s back.
I might think of trying the ZCMD,maybe it will help,but any other suggestions?[i will edit if its working]
Until then,please suggest me what to do.
Reply
#4

I think it might be this:

Код:
OnCarUpdate();
It looks like your updating every vehicle currently loaded in game and not the one car that needs updating? But that's just an observation because you didn't provide that in your code.
Reply
#5

I still dont get it,i loocked in public oncarupdate ,i think the problem is from new idx = carsonserver but i dont really dont know how to fix it.

PHP код:
public OnCarUpdate()
{
    new 
idx;
    new 
Filefile2;
    
idx carsonserver;
     while (
idx sizeof(CarInfo))
    {
        new 
coordsstring[256];
        
format(coordsstringsizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
        
CarInfo[idx][cModel],
        
CarInfo[idx][cLocationx],
        
CarInfo[idx][cLocationy],
        
CarInfo[idx][cLocationz],
        
CarInfo[idx][cAngle],
        
CarInfo[idx][cColorOne],
        
CarInfo[idx][cColorTwo],
        
CarInfo[idx][cOwner],
        
CarInfo[idx][cDescription],
        
CarInfo[idx][cValue],
        
CarInfo[idx][cOwned],
        
CarInfo[idx][mod1],
        
CarInfo[idx][mod2],
        
CarInfo[idx][mod3],
        
CarInfo[idx][mod4],
        
CarInfo[idx][mod5],
        
CarInfo[idx][mod6],
        
CarInfo[idx][mod7],
        
CarInfo[idx][mod8],
        
CarInfo[idx][mod9],
        
CarInfo[idx][mod10],
        
CarInfo[idx][mod11],
        
CarInfo[idx][mod12],
        
CarInfo[idx][mod13],
        
CarInfo[idx][mod14],
        
CarInfo[idx][mod15],
        
CarInfo[idx][mod16],
        
CarInfo[idx][mod17],
        
CarInfo[idx][paintjob]);
        if(
idx == carsonserver)
        {
            
file2 fopen("masini.cfg"io_write);
        }
        else
        {
            
file2 fopen("masini.cfg"io_append);
        }
        
fwrite(file2coordsstring);
        
idx++;
        
fclose(file2);
    }
    return 
1;

I really apreciate your support guys,thanks.
Reply
#6

Opening, writing and closing files 2000 times. You set idx to the value "carsonserver" is so what's the point of checking all the time instead of just opening the file once.

Plus you never check for invalid file handles and that can crash the server and declaring a string 2000 times as well (keep it outside of the loop).

PHP код:
public OnCarUpdate()
{
    new 
coordsstring[256], Filefile2 fopen("masini.cfg"io_write);
    
    if (!
file2) return 0;
    
    for (new 
idx carsonserveridx != sizeof (CarInfo); ++idx)
    {
        
format(coordsstringsizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
        
CarInfo[idx][cModel],
        
CarInfo[idx][cLocationx],
        
CarInfo[idx][cLocationy],
        
CarInfo[idx][cLocationz],
        
CarInfo[idx][cAngle],
        
CarInfo[idx][cColorOne],
        
CarInfo[idx][cColorTwo],
        
CarInfo[idx][cOwner],
        
CarInfo[idx][cDescription],
        
CarInfo[idx][cValue],
        
CarInfo[idx][cOwned],
        
CarInfo[idx][mod1],
        
CarInfo[idx][mod2],
        
CarInfo[idx][mod3],
        
CarInfo[idx][mod4],
        
CarInfo[idx][mod5],
        
CarInfo[idx][mod6],
        
CarInfo[idx][mod7],
        
CarInfo[idx][mod8],
        
CarInfo[idx][mod9],
        
CarInfo[idx][mod10],
        
CarInfo[idx][mod11],
        
CarInfo[idx][mod12],
        
CarInfo[idx][mod13],
        
CarInfo[idx][mod14],
        
CarInfo[idx][mod15],
        
CarInfo[idx][mod16],
        
CarInfo[idx][mod17],
        
CarInfo[idx][paintjob]);

        
fwrite(file2coordsstring);
    }
    
fclose(file2);
    return 
1;

Reply
#7

Make a new function called OnUpdateVehicle(vehicleid)

copy everything from OnCarUpdate(); and make idx = vehicleid;

that should work for it.
Reply
#8

EDIT: IT IS WORKING,thanks azzerking for support and Konstantinos for the solution. THANKS Konstantinos,it worked!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)