Help :D
#1

How i can make that command's to "read" faster

pawn Код:
if (strcmp(cmd, "/buyveh", true) ==0 )
    {
    if(dini_Int(PFile(playerid),"HaveCar")== 1) return SendClientMessage(playerid,ORANGE,"{3BB9FF}[GAMEFRONT]:{FFFFFF} {FF0000}[ERROR]{FFFFFF} Tu Ai Deja O masina Cumparata!");
    format(string,sizeof(string),"GameFrontPCars/Users/%s.ini",tmp);
    dini_Remove(string);
   
    if(!IsPlayerInAnyVehicle(playerid)){return 1;}
    if(GetCreatorID(vehicleid)!=0)
    {
    if (strmatch(VehicleSystem[GetCreatorID(vehicleid)][owner],Spielername(playerid))){SendClientMessage(playerid,WHITE," {3BB9FF}[GAMEFRONT]:{FFFFFF} Aceasta masina este deja cumparata!");return 1;}
    if (strmatch(VehicleSystem[GetCreatorID(vehicleid)][owner],"dealercar"))
    {
    if(VehicleSystem[GetCreatorID(vehicleid)][preis] < GetPlayerMoney(playerid))
    {
    strmid(VehicleSystem[GetCreatorID(vehicleid)][owner],Spielername(playerid),0,128,128);
    VehicleSystem[GetCreatorID(vehicleid)][owned]=1;
    SetVehicleNumberPlate(vehicleid, VehicleSystem[GetCreatorID(vehicleid)][owner]);
    GivePlayerMoney(playerid,-VehicleSystem[GetCreatorID(vehicleid)][preis]);
    SendClientMessage(playerid,YELLOW," {3BB9FF}[GAMEFRONT]:{FFFFFF} Felicitari pentru noua achizitie!");
    SendClientMessage(playerid,WHITE," {3BB9FF}[GAMEFRONT]:{FFFFFF} Poti vedea comenzile la masina utilizand comanda {3BB9FF}/carhelp");
    TogglePlayerControllable(playerid,1);
    SaveTool();
    Carlabel(playerid);
    }
    else
    {
    SendClientMessage(playerid,WHITE,"{3BB9FF}[GAMEFRONT]:{FFFFFF} Ai nevoie de mai multi bani!");
    }
    }
    else
    {
    SendClientMessage(playerid,WHITE,"{3BB9FF}[GAMEFRONT]:{FFFFFF} Aceasta masina nu e de vanzare!");
    }
    }
    else
    {
    SendClientMessage(playerid,WHITE,"{3BB9FF}[GAMEFRONT]:{FFFFFF} Nu e de vanzare!");
    }
    if(!dini_Exists(PFile(playerid)))
    {
        dini_Create(PFile(playerid));
        dini_IntSet(PFile(playerid),"HaveCar",1);
        dini_IntSet(PFile(playerid),"CarID",vehicleid);
    }
    else if(dini_Exists(PFile(playerid)))
    {
        dini_IntSet(PFile(playerid),"HaveCar",1);
        dini_IntSet(PFile(playerid),"CarID",vehicleid);
    }
    return 1;
    }
pawn Код:
if (strcmp(cmd, "/sellveh", true) ==0)
    {
    if(!IsPlayerInAnyVehicle(playerid)){return 1;}
    if(GetCreatorID(vehicleid)!=0)
    {
    if (strmatch(VehicleSystem[GetCreatorID(vehicleid)][owner],Spielername(playerid)))
    {
    tmp = strtok(cmdtext,idx);
    if(!strlen(tmp)){SendClientMessage(playerid,WHITE,"{3BB9FF}[GAMEFRONT]:{FFFFFF} INFO: /sellveh [pret]");return 1;}
    new Float:vx,Float:vy,Float:vz,Float:va;
    GetVehiclePos(GetPlayerVehicleID(playerid),vx,vy,vz);
    GetVehicleZAngle(GetPlayerVehicleID(playerid),va);
    VehicleSystem[GetCreatorID(vehicleid)][x]=vx;
    VehicleSystem[GetCreatorID(vehicleid)][y]=vy;
    VehicleSystem[GetCreatorID(vehicleid)][z]=vz;
    VehicleSystem[GetCreatorID(vehicleid)][a]=va;
    VehicleSystem[GetCreatorID(vehicleid)][preis]=strval(tmp);
    VehicleSystem[GetCreatorID(vehicleid)][owned]=0;
    strmid(VehicleSystem[GetCreatorID(vehicleid)][owner],"dealercar",0,128,128);
    SendClientMessage(playerid,WHITE,"{3BB9FF}[GAMEFRONT]:{FFFFFF} Aceasta masina e acum de vanzare!");
    SaveTool();
    Carlabel(playerid);
    format(string,sizeof(string),"GameFrontPCars/Users/%s.ini",tmp);
    dini_Remove(string);
    }
    else
    {
    SendClientMessage(playerid,WHITE,"{3BB9FF}[GAMEFRONT]:{FFFFFF} INFO: Nu poti vinde masina asta,nu este ata!");
    }
    }
    return 1;
    }
pawn Код:
if (strcmp(cmd, "/park", true) ==0 )
    {
    if(!IsPlayerInAnyVehicle(playerid)){return 1;}
    if(GetCreatorID(vehicleid)!=0)
    {
    if (strmatch(VehicleSystem[GetCreatorID(vehicleid)][owner],Spielername(playerid)))
    {
    new Float:vx,Float:vy,Float:vz,Float:va;
    GetVehiclePos(GetPlayerVehicleID(playerid),vx,vy,vz);
    GetVehicleZAngle(GetPlayerVehicleID(playerid),va);
    VehicleSystem[GetCreatorID(vehicleid)][x]=vx;
    VehicleSystem[GetCreatorID(vehicleid)][y]=vy;
    VehicleSystem[GetCreatorID(vehicleid)][z]=vz;
    VehicleSystem[GetCreatorID(vehicleid)][a]=va;
    SetVehicleHealth(GetPlayerVehicleID(playerid),100.0);
    SendClientMessage(playerid,WHITE,"{3BB9FF}[GAMEFRONT]:{FFFFFF} Masina a fost parcata aici!");
    SendClientMessage(playerid,YELLOW,"{3BB9FF}[GAMEFRONT]:{FFFFFF} Masina se va respawna aici!");
    SaveTool();
    }
    }
    return 1;
    }
When i use them it's an 5-10 seconds lag delay
Reply
#2

1: Don't use DINI; switch to DJSON.
Both are made by Dracoblue. Differences between the two:

"DINI" = "DJSON"
dini_IntGet (or something like that) = djInt
dini_IntSet = djSetInt
dini_Get = dj
dini_Set = djSet
dini_FloatGet = djFloat
dini_FloatSet = djSetFloat
(etcetera).

And the only other difference is:
In OnGameModeInit or OnFilterScriptInit, you must place djson_GameModeInit();, and the same for OnGameMode/OnFilterScript-Exit: djson_GameModeExit();

So put 'djson.inc' in your 'pawno/include' folder, change #include <dini> to #include <djson> and you can use CTRL+H to change the DINI functions to the DJSON ones. If you still don't understand it, you may send your gamemode (.pwn file) to my over PM (I won't give it to other and I won't use it myself - The reason for the PM is so that others won't have it).

Also, you shouldn't use strcmp (OnPlayerCommandText), but ZCMD.

"strcmp":
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp(cmdtext, "/help", false))
    {
        //Command stuff here
        return 1;
    }
    if (!strcmp(cmdtext, "/kill", false))
    {
        //Command stuff here
        return 1;
    }
    return 0;
}
In ZCMD, this would be:
pawn Код:
CMD:help(playerid, params[])
{
    //Command stuff here
    return 1;
}

CMD:kill(playerid, params[])
{
    //Command stuff here
    return 1;
}
ZCMD is easier to use, and faster. However, switching from strcmp to ZCMD does take more time. You should also use sscanf2 when using zcmd (which also is easier to use). Example:

PM function in ZCMD:
pawn Код:
CMD:pm(playerid, params[])
{
    new playerId, messageTxt[75], fullStr[128];
    new yourName[MAX_PLAYER_NAME], sendName[MAX_PLAYER_NAME];
    if (sscanf(params, "ds[75]", playerId, messageTxt))
        return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /pm [playerid] [message]");
    if (playerId == playerid || !IsPlayerConnected(playerId))
        return SendClientMessage(playerid, COLOR_RED, "* The user you are trying to send the message to isn't connected or is yourself!");

    GetPlayerName(playerid, yourName, MAX_PLAYER_NAME);
    GetPlayerName(playerId, sendName, MAX_PLAYER_NAME);

    format(fullStr, 128, "* PM from %s(%d): %s", yourName, playerid, messageTxt);
    SendClientMessage(yourId, COLOR_YELLOW, fullStr);
    format(fullStr, 128, "* PM sent to %s(%d): %s", sendName, playerId, messageTxt);
    SendClientMessage(playerid, COLOR_GREEN, fullStr);
    return 1;
}
That would be alot easier then using strtok and everyhting.

Kind regards,
Kwarde
Reply
#3

Quote:
Originally Posted by Kwarde
Посмотреть сообщение
1: Don't use DINI; switch to DJSON.
Both are made by Dracoblue. Differences between the two:

"DINI" = "DJSON"
dini_IntGet (or something like that) = djInt
dini_IntSet = djSetInt
dini_Get = dj
dini_Set = djSet
dini_FloatGet = djFloat
dini_FloatSet = djSetFloat
(etcetera).

And the only other difference is:
In OnGameModeInit or OnFilterScriptInit, you must place djson_GameModeInit();, and the same for OnGameMode/OnFilterScript-Exit: djson_GameModeExit();

So put 'djson.inc' in your 'pawno/include' folder, change #include <dini> to #include <djson> and you can use CTRL+H to change the DINI functions to the DJSON ones. If you still don't understand it, you may send your gamemode (.pwn file) to my over PM (I won't give it to other and I won't use it myself - The reason for the PM is so that others won't have it).

Also, you shouldn't use strcmp (OnPlayerCommandText), but ZCMD.

"strcmp":
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp(cmdtext, "/help", false))
    {
        //Command stuff here
        return 1;
    }
    if (!strcmp(cmdtext, "/kill", false))
    {
        //Command stuff here
        return 1;
    }
    return 0;
}
In ZCMD, this would be:
pawn Код:
CMD:help(playerid, params[])
{
    //Command stuff here
    return 1;
}

CMD:kill(playerid, params[])
{
    //Command stuff here
    return 1;
}
ZCMD is easier to use, and faster. However, switching from strcmp to ZCMD does take more time. You should also use sscanf2 when using zcmd (which also is easier to use). Example:

PM function in ZCMD:
pawn Код:
CMD:pm(playerid, params[])
{
    new playerId, messageTxt[75], fullStr[128];
    new yourName[MAX_PLAYER_NAME], sendName[MAX_PLAYER_NAME];
    if (sscanf(params, "ds[75]", playerId, messageTxt))
        return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /pm [playerid] [message]");
    if (playerId == playerid || !IsPlayerConnected(playerId))
        return SendClientMessage(playerid, COLOR_RED, "* The user you are trying to send the message to isn't connected or is yourself!");

    GetPlayerName(playerid, yourName, MAX_PLAYER_NAME);
    GetPlayerName(playerId, sendName, MAX_PLAYER_NAME);

    format(fullStr, 128, "* PM from %s(%d): %s", yourName, playerid, messageTxt);
    SendClientMessage(yourId, COLOR_YELLOW, fullStr);
    format(fullStr, 128, "* PM sent to %s(%d): %s", sendName, playerId, messageTxt);
    SendClientMessage(playerid, COLOR_GREEN, fullStr);
    return 1;
}
That would be alot easier then using strtok and everyhting.

Kind regards,
Kwarde
P.M. send !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)