SA-MP Forums Archive
Check if player gained something - 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: Check if player gained something (/showthread.php?tid=287524)



Check if player gained something - lukas567 - 03.10.2011

Is there any Includes that checks:
1. If player recieved money
2. If player recieved wanted level
3. If player is running [SOLVED]

These includes must not use much of memory.
Thanks!


Re: Check if player gained something - Pharrel - 03.10.2011

for the last one you can use

pawn Код:
new animlib[32], animtmp[32];
GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animtmp,32);

if(!strcmp(animtmp, "run_civi",true))//so the player is running



Re: Check if player gained something - lukas567 - 03.10.2011

Thanks! For other questions waiting answers


Re: Check if player gained something - PowerPC603 - 03.10.2011

You could create a timer which runs every second or so.
In this timer, you get the player's money and wanted level and store those values somewhere.
As the timer runs again after a second, you get the money and wanted level again and check it against the previous values.
By storing the values when they have increased, you make sure you only get the message once.

pawn Код:
enum PlayerData
{
    Money, WantedLevel
}
new pData[MAX_PLAYERS][PlayerData];


SetTimer("Timer1", 1000, true);


forward Timer1();
public Timer1()
{
    new pMoney, Wanted;

    for (new playerid; playerid < MAX_PLAYERS; playerid++)
    {
        pMoney = GetPlayerMoney(playerid);
        Wanted = GetPlayerWantedLevel(playerid);

        if (pMoney > pData[playerid][Money])
        {
            pData[playerid][Money] = pMoney;
            SendClientMessage(playerid, 0xFFFFFFFF, "You've earned money");
        }
        if (Wanted > pData[playerid][WantedLevel])
        {
            pData[playerid][WantedLevel] = Wanted;
            SendClientMessage(playerid, 0xFFFFFFFF, "Your wanted level has increased");
        }
    }
}
Something like this is small and can be used for such things.