/tk... help.
#1

Hello everyone there a are no problem but i want to add timer for ticket timer for someone payed it.


PHP код:
COMMAND:tk(playerid,params[])
{
    new 
pId;
    new 
pskin GetPlayerSkin(playerid);
    if(
pskin == 265 || pskin == 266 || pskin == 267 || pskin == 280 || pskin == 281 || pskin == 284 || pskin == 285 || pskin == 286 || pskin == 287 || pskin == 288)
    {
        if(
sscanf(params"d"pId)) return SendClientMessage(playerid0xFF0000AA"Usage: /tk [ID]");
            else if(!
IsPlayerConnected(pId)) return SendClientMessage(playerid0xFF0000AA"[WARRING]:- The Player is not Connected/Invaild ID.");
                else
                {
                    new 
Float:xFloat:yFloat:z;
                    
GetPlayerPos(pIdxyz);
                    if(
IsPlayerInRangeOfPoint(playerid12.0xyz))
                    {
                        new 
pname[MAX_PLAYER_NAME], aname[MAX_PLAYER_NAME], string1[250];
                        
GetPlayerName(playeridpnamesizeof(pname));
                        
GetPlayerName(pIdanamesizeof(aname));
                        if (
GetPlayerWantedLevel(pId) == 0)
                        {
                            
SendClientMessage(playerid0xFF0000AA"{952C35}[WARRING]{FFFFFF}: This player is not wanted to ticket him.");
                            return 
1;
                        }
                        else if (
GetPlayerWantedLevel(pId) == 3)
                        {
                            
SendClientMessage(pId0xFF0000AA"[PAYED]:- The Player has been payed his ticket. [automacily].");
                            
GivePlayerMoney(pId, -3500);
                            
GameTextForPlayer(pId"~b~Ticket Payed"50003);
                            
GivePlayerMoney(playerid3500);
                            
SendClientMessage(playerid0xFF0000AA"[Getting]: You have got $3500, The player payed his ticket.");
                            
SetPlayerScore(playeridGetPlayerScore(playerid) + 1);
                            
SetPlayerWantedLevel(pId0);
                            
SetPlayerColor(pIdCOLOR_WHITE);
                            
format(string1sizeof(string1), "%s(%d) Has Recieved A Ticket From Officer {0080FF}%s(%d)"anamepIdpnameplayerid);
                            
SendClientMessageToAll(0xFF0000AAstring1);
                            return 
1;
                        }
                        else if (
GetPlayerWantedLevel(pId) > 1)
                        {
                            
SendClientMessage(playerid0xFF0000AA"{952C35}[WARRING]{FFFFFF}: You can ticket this player type /ticket.");
                            return 
1;
                        }
                    }
                }
               }
               else
               {
                   return 
SendClientMessage(playerid0xFF0000AA"{FF0017}[ERROR]{FFFFFF}: Only Cops can use this command.");
            }
    return 
1;

I'm adding this command to my server but there a problem. What is it? Read below..

I want add a ticket timer what i mean? : When i need to /tk [SOMEONE] Given him 25 secdons for payed if he not +4Stars on him how to do that?


I Want add /pay for payed the ticket money$$ how to do that?!
Reply
#2

There's many ways but my recommendation would be a timer with a countdown

PHP код:
//Countdown timer
new TKCountDown[MAX_PLAYERS];
new 
TKTimer[MAX_PLAYERS];

//somewhere in your tk code
TKCountdown[pID] = 25;
TKTimer[pID] = SetTimerEx("TicketCountdown""1000"true"d"pID"); 


//Create your custom forward public function
forward TicketWait(playerid);

public TicketWait(playerid)
{
       if(TicketCountDown[playerid] > 0)
       {
              TicketCountDown[playerid]--;
        }
        else
       {
            KillTimer(TicketTimer[playerid])
            //Your code here. or simply the warning thing
       }
}

CMD:pay(playerid, params[])
{
    //Your code here

    //In The end part
   KillTimer(TicketTimer[pID]);
   TicketCountDown[pID] = 0;
    return 1;

Just something like that...
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)