Code still not working :S
#1

Im trying to decrease wanted level and my code just not working :S

Any help??

pawn Код:
#include <a_samp>

#define YELLOW                  0xFFFF00FF

public OnGameModeInit()
{
    SetTimer("wantedto5",120000,true);
    SetTimer("wanted5to4",120000,true);
    SetTimer("wanted4to3",120000,true);
    SetTimer("wanted3to2",120000,true);
    SetTimer("wanted2to1",120000,true);
    SetTimer("wanted1to0",120000,true);
   
    return 1;
}


forward wantedto5(playerid);
public wantedto5(playerid)
{
    if(GetPlayerWantedLevel(playerid) >= 6)
    {
    SetPlayerWantedLevel(playerid,5);
    SendClientMessage(playerid, YELLOW,"[WANTED] You Have Lost A Wanted Level![Level 5]");
}
}

forward wanted5to4(playerid);
public wanted5to4(playerid)
{
    if(GetPlayerWantedLevel(playerid) == 5)
    {
    SetPlayerWantedLevel(playerid,4);
    SendClientMessage(playerid, YELLOW,"[WANTED] You Have Lost A Wanted Level![Level 4]");
}
}

forward wanted4to3(playerid);
public wanted4to3(playerid)
{
    if(GetPlayerWantedLevel(playerid) == 4)
    {
    SetPlayerWantedLevel(playerid,3);
    SendClientMessage(playerid, YELLOW,"[WANTED] You Have Lost A Wanted Level![Level 3]");
}
}

forward wanted3to2(playerid);
public wanted3to2(playerid)
{
    if(GetPlayerWantedLevel(playerid) == 3)
    {
    SetPlayerWantedLevel(playerid,2);
    SendClientMessage(playerid, YELLOW,"[WANTED] You Have Lost A Wanted Level![Level 2]");
}
}

forward wanted2to1(playerid);
public wanted2to1(playerid)
{
    if(GetPlayerWantedLevel(playerid) == 2)
    {
    SetPlayerWantedLevel(playerid,1);
    SendClientMessage(playerid, YELLOW,"[WANTED] You Have Lost A Wanted Level![Level 1]");
}
}

forward wanted1to0(playerid);
public wanted1to0(playerid)
{
    if(GetPlayerWantedLevel(playerid) == 1)
    {
    SetPlayerWantedLevel(playerid,0);
    SendClientMessage(playerid, YELLOW,"[WANTED] You Have Lost Your Wanted Level![Innocent]");
}
}
Reply
#2

Try this:

pawn Код:
#include <a_samp>

#define YELLOW                  0xFFFF00FF

public OnPlayerConnect(playerid)
{
    SetTimerEx("decWantedLevel",2*60*1000,true, "i", playerid);
    return 1;
}


forward decWantedLevel(playerid);
public decWantedLevel(playerid)
{
    if(GetPlayerWantedLevel(playerid) > 5)
    {
        SetPlayerWantedLevel(playerid,5);
        SendClientMessage(playerid, YELLOW,"[WANTED] You Have Lost A Wanted Level![Level 5]");
    }
    else if(GetPlayerWantedLevel(playerid) == 5)
    {
        SetPlayerWantedLevel(playerid,4);
        SendClientMessage(playerid, YELLOW,"[WANTED] You Have Lost A Wanted Level![Level 4]");
    }
    else if(GetPlayerWantedLevel(playerid) == 4)
    {
        SetPlayerWantedLevel(playerid,3);
        SendClientMessage(playerid, YELLOW,"[WANTED] You Have Lost A Wanted Level![Level 3]");
    }
    else if(GetPlayerWantedLevel(playerid) == 3)
    {
        SetPlayerWantedLevel(playerid,2);
        SendClientMessage(playerid, YELLOW,"[WANTED] You Have Lost A Wanted Level![Level 2]");
    }
    else if(GetPlayerWantedLevel(playerid) == 2)
    {
        SetPlayerWantedLevel(playerid,1);
        SendClientMessage(playerid, YELLOW,"[WANTED] You Have Lost A Wanted Level![Level 1]");
    }
    else if(GetPlayerWantedLevel(playerid) == 1)
    {
        SetPlayerWantedLevel(playerid,0);
        SendClientMessage(playerid, YELLOW,"[WANTED] You Have Lost Your Wanted Level![Innocent]");
    }
}
Reply
#3

You need playerid as an argument to the function, but SetTimer does not send this, so the function isnt called. Use SetTimerEx for that ( SetTimerEx("func", time, true, "i", playerid) )

However, you could also limit all your functions to one, that just decreases the wanted level by one and sends a message depending on the new level, as it would only need one timer instead of 6.

Edit: arr, Larzi was faster
Reply
#4

@ Larzi thankyou so much it works

@ Mauzen thankyou for explaining that
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)