SA-MP Forums Archive
A server problem. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: A server problem. (/showthread.php?tid=519532)



A server problem. - VladimirMark - 14.06.2014

Hello, I get this message every second in the game "You need %d respect points! You only have [%d] !
How can I stop that. Here is the code.
pawn Код:
buylevel()
{
    foreach(Player, i)
    {
    new nxtlevel = GetPVarInt(i, "Level")+1;
    //new costlevel = nxtlevel*levelcost;
    new expamount = nxtlevel*levelexp;
    new infostring[96];
    new exp = GetPVarInt(i, "RespectPoints");
    if (exp < expamount)
    {
        format(infostring, sizeof(infostring), "   You need %d respect points! You only have [%d] !",expamount,GetPVarInt(i,"RespectPoints"));
        SendClientMessage(i, COLOR_LIGHTRED, infostring);
        continue;
    }
        format(infostring, sizeof(infostring), "~g~LEVEL UP~n~~w~You Are Now Level %d", nxtlevel);
        GameTextForPlayer(i, infostring, 5000, 1);
        PlayerPlaySound(i, 1052, 0.0, 0.0, 0.0);
        PlayerPlayMusic(i);
        //GiveMoneyEx(playerid, -costlevel);
        SetPVarInt(i, "Level", nxtlevel);
        SetPlayerScore(i, nxtlevel);
        exp -= expamount;
        SetPVarInt(i, "RespectPoints", exp);
    }

}
Thank you very much.


Re: A server problem. - cleanboy - 14.06.2014

Quote:
Originally Posted by VladimirMark
Посмотреть сообщение
Hello, I get this message every second in the game "You need %d respect points! You only have [%d] !
How can I stop that. Here is the code.
pawn Код:
buylevel()
{
    foreach(Player, i)
    {
    new nxtlevel = GetPVarInt(i, "Level")+1;
    //new costlevel = nxtlevel*levelcost;
    new expamount = nxtlevel*levelexp;
    new infostring[96];
    new exp = GetPVarInt(i, "RespectPoints");
    if (exp < expamount)
    {
        format(infostring, sizeof(infostring), "   You need %d respect points! You only have [%d] !",expamount,GetPVarInt(i,"RespectPoints"));
        SendClientMessage(i, COLOR_LIGHTRED, infostring);
        continue;
    }
        format(infostring, sizeof(infostring), "~g~LEVEL UP~n~~w~You Are Now Level %d", nxtlevel);
        GameTextForPlayer(i, infostring, 5000, 1);
        PlayerPlaySound(i, 1052, 0.0, 0.0, 0.0);
        PlayerPlayMusic(i);
        //GiveMoneyEx(playerid, -costlevel);
        SetPVarInt(i, "Level", nxtlevel);
        SetPlayerScore(i, nxtlevel);
        exp -= expamount;
        SetPVarInt(i, "RespectPoints", exp);
    }

}
Thank you very much.
try this, change this to
Код:
continue;
this
Код:
return 1;



AW: A server problem. - Nero_3D - 15.06.2014

Well you probably call buylevel() in some timer or in OnPlayerUpdate but you only need to call it if the players buys / reaches a new level and that only happens if the player earned exp

To stop the messages just remove them if they are gaining the levels just by reaching a certain exp


Re: A server problem. - VladimirMark - 15.06.2014

Fixed it, I had a command that I had /* "code" */
Any way I have another warning now,
Warning:
Код:
gamemodes\tkgaming.pwn(1149) : warning 219: local variable "query" shadows a variable at a preceding level
Line 1149-1157:
pawn Код:
public OnQueryError( errorid, error[], callback[], query[], connectionHandle ) {
    #if debug
        new msg[256];
        format(msg,sizeof(msg),"SQL ERROR: %d %s",errorid, error);
        printf(msg);
        ABroadcast(X11_RED, msg, EAdminFlags_All);
    #endif
    return 0;
}



Re: A server problem. - Konstantinos - 15.06.2014

You've declared "query" as a global array. Re-name it to something else or declare it locally.


Re: A server problem. - VladimirMark - 15.06.2014

If I want to rename it, should I make it like "queryr[]" ??


Re: A server problem. - Konstantinos - 15.06.2014

I meant the global variable to be re-named and anywhere else it's used.


Re: A server problem. - VladimirMark - 15.06.2014

The "query[]" Its global?
I can't understand


Re: A server problem. - Konstantinos - 15.06.2014

https://sampwiki.blast.hk/wiki/Scripting_Basics#global