Timer saves wrongly...
#1

Hello samp forum members thank you for reading my topic and code.

Maybe someone could help me out with it..
I can't find whats going wrong...


INI FILE:

pawn Код:
CMDT=1383562867
OnGameModeInit:

pawn Код:
SetTimer("GlobalCheck",1000,true);
Global checking:
pawn Код:
forward GlobalCheck();
public GlobalCheck()
{
    foreach(Player,i)
    {
        if(PlayerInfo[i][pCMDT] > 0 && gettime() <= PlayerInfo[i][pCMDT])
        {
            PlayerInfo[i][pCMDT] = 0;
            SendClientMessage(i,0xFFFFFFFF,"The /giverespect command is ready for use once more.");
        }
    }
    return 1;
}
CMD:

pawn Код:
CMD:giverespect(playerid, params[])
{
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pCMDT] > 0)return SendClientMessage(playerid,0xFF0000FF,"Please wait before using this command again.");
    if(PlayerInfo[playerid][pCMDT] <= 0)
    {
        new id, string[128];
        if(sscanf(params, "r", id)) return SendClientMessage(playerid, 0xCC0000AA, "USAGE: /respect <playerid/partofname>");
        if(IsPlayerInRangeOfPlayer(playerid, id, 5))
        {
            if(playerid != id)
            {
                PlayerInfo[playerid][pStreetRespect]++;
                PlayerInfo[playerid][pCMDT] = gettime() + 3600;
                if((gettime() - PlayerInfo[playerid][pCMDT]) > 3600)
                format(string, sizeof(string), " You have gived Street Respect to %s.", NORPN(id));
                SendClientMessage(playerid, COLOR_WHITE, string);
                format(string, sizeof(string), " Player %s has gived you Street Respect to you.", NORPN(playerid));
                SendClientMessage(playerid, COLOR_WHITE, string);
            }
        }
        else
        {
            SendClientMessage(playerid, -1, "You can't heal yourself.");
        }
    }
    else
    {
        SendClientMessage(playerid, -1, "You aren't close enough to the player.");
    }
    return 1;
}
Reply
#2

pawn Код:
forward GlobalCheck();
public GlobalCheck()
{
    foreach(Player,i)
    {
        if(PlayerInfo[i][pCMDT] > 0)
            if(--PlayerInfo[i][pCMDT] < 1)
            {
                PlayerInfo[i][pCMDT] = 0;
                SendClientMessage(i,0xFFFFFFFF,"The /giverespect command is ready for use once more.");
            }
    }
    return 1;
}

CMD:giverespect(playerid, params[])
{
    if(!IsPlayerLoggedIn(playerid)) SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    else if(PlayerInfo[playerid][pCMDT] > 0) SendClientMessage(playerid,0xFF0000FF,"Please wait before using this command again.");
    else{
        new id;
        if(sscanf(params, "u", id)) SendClientMessage(playerid, 0xCC0000AA, "USAGE: /respect <playerid/partofname>");
        else if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id)) SendClientMessage(playerid, -1, "ID not connected");
        else if(playerid == id) SendClientMessage(playerid, -1, "You can't heal yourself.");
        else if(!IsPlayerInRangeOfPlayer(playerid, id, 5)) SendClientMessage(playerid, -1, "You aren't close enough to the player.");
        else{
            new string[128];
            PlayerInfo[playerid][pStreetRespect]++;
            PlayerInfo[playerid][pCMDT] = Time_Here; // example 3600 - 1 hour
            format(string, sizeof(string), " You have gived Street Respect to %s.", NORPN(id));
            SendClientMessage(playerid, COLOR_WHITE, string);
            format(string, sizeof(string), " Player %s has gived you Street Respect to you.", NORPN(playerid));
            SendClientMessage(id, COLOR_WHITE, string);
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)