A server problem.
#1

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.
Reply
#2

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;
Reply
#3

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
Reply
#4

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;
}
Reply
#5

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

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

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)