only ID 0 player gets jail count..
#1

first, my JAIL command:

pawn Код:
COMMAND:jail(playerid, params[])
{
    if(GetPlayerColor(playerid) == 0x0259EAAA)


    {
        new toplayer;
        if(!sscanf(params, "ui", toplayer))


        {
            if(IsPlayerConnected(toplayer))


            {

                new Float:X, Float:Y, Float:Z;
                GetPlayerPos(playerid, X,Y,Z);
                if(IsPlayerInRangeOfPoint(toplayer, 1.0, X,Y,Z))


                {
                    new string[64];
                    new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
                    GetPlayerName(playerid, name, sizeof(name));
                    GetPlayerName(toplayer, PlayerName, sizeof(PlayerName));
                    format(string, sizeof(string), "Cop %s jailed u with 60 sec jail time!", name);
                    SendClientMessage(toplayer, 0xFFFF00FF, string);
                    format(string, sizeof(string), "You jailed player: %s", PlayerName);
                    SendClientMessage(playerid, 0xFFFF00FF, string);
                    SetPlayerPos(toplayer, 264.6288,77.5742,1001.0391);
                    SetPlayerInterior(toplayer, 6);
                    jailed[toplayer] = 1;

                    SetTimer("UnJail",60000,false);  //IMPORTANT
                    TextDrawShowForPlayer(toplayer,Textdraw7);
                    TextDrawShowForPlayer(toplayer,Textdraw6);
                    TextDrawShowForPlayer(toplayer,Textdraw8);

                    timer = SetTimerEx("test", 1000, 1, "d", toplayer); //IMPORTANT
                    return 1;


                }

                else return SendClientMessage(playerid, 0xFFFF00FF, "You not close to a player.");


            }
            else return SendClientMessage(playerid, 0xFFFF00FF, "Player not on server.");


        }
        else return SendClientMessage(playerid, 0xFFFF00FF, "Use: /jail [ID player/part of name]");


    }
    else return SendClientMessage(playerid, 0xFFFF00FF, "You not the cop!");

}

and the UNJAIL COUNTER and COUNT TIMER:

pawn Код:
public test()                             //this is for JAIL COUNT

{
    new toplayer;




    {
        if(jailed[toplayer] == 1)



        {

            count--; //Use ++ for counting forwards, and -- for counting the seconds backwards
            new string[24];
            format(string, sizeof(string), "~y~%d seconds", count);
            return TextDrawSetString(Textdraw8, string);



        }
        return 1;



    }

}

public UnJail()
{
    for(new v; v < MAX_PLAYERS; v++)



    {
        if(jailed[v] == 1)



        {

            SetPlayerPos(v, 1552.9241,-1675.1953,16.1953);
            SetPlayerInterior(v, 0);
            jailed[v] = 0;
            KillTimer(timer);
            count = 60;
            TextDrawHideForPlayer(v, Textdraw6);
            TextDrawHideForPlayer(v, Textdraw7);
            TextDrawHideForPlayer(v, Textdraw8);




        }
        return 1;



    }
    return 1;
}

there,and only player with ID 0 get properly JAIL COUNT with 60 seconds counting backwards, but when I jail other player, he shares the same count
so if player with ID 0 is at 36 SECONDS of jailtime, the other JAILED ID will be at the same time and he'll go in minus -24 and there, counter stops,but the problem is also,player with NON ID 0 will not be set to interior 0,will not be free then?
Reply
#2

Use SetTimerEx instead of SetTimer. When I was a beginner in PAWN I also had this error.

SetTimerEx is used for call a function with arguments.

Usage:

pawn Код:
SetTimerEx(FuncName[], Interval, Repeating, const format, Float{.._});
Example:

pawn Код:
SetTimerEx("YourFunc", 10000, false, "i", playerid);
How to use "i", "s", and "f":

i = integer: For Example class IDs, like players, vehicles and objects.
s = string: For example messages, filenames etc...
f = float: For example coordinates

Example:

pawn Код:
SetTimerEx("YourFunc", 10000, false, "iiifffs", playerid, objectid, vehicleid, x, y, z, "Hello");
Reply
#3

thx mate,you're great

Im trying to fix it now,no luck at first couple of tries :d it will took some time or I'll call back here
Reply
#4

omg,finally I fixed it

I needed settimerex and also to define [MAX_PLAYERS] on counter and on textdraw too
wow that took a while
Reply
#5

Also if I may point out, you are using only "toplayer", but why do you use 2 sscanf variable for that...?

pawn Код:
if(!sscanf(params, "ui", toplayer)//"i" is not needed
Reply
#6

I see I was just playing safe ty man
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)