Job Payment...
#8

pawn Код:
new pCall[MAX_PLAYERS];

#define MAX_CALL_COST 50


public OnGameModeInit()
{
    SetTimer("CallCost", 60007, 1);
}

public OnPlayerConnect(playerid)
{
    pCall[playerid] = 0;
}

public OnPlayerDisconnect(playerid)
{
    pCall[playerid] = 0;
}

forward CallCost();
public CallCost()
{
    for( new playerid=0; playerid < MAX_PLAYERS; playerid++ )
    {
        if( pCall[playerid] )
        {
            switch( pCall[playerid] )
            {
                case 555: {
                    if( GetPlayerMoney(playerid) < MAX_CALL_COST )
                    {
                        pCall[playerid] = 0;
                        SetPlayerSpecialAction(playerid,SPECIAL_ACTION_STOPUSECELLPHONE);
                        PhoneMsg(playerid,"Phone Operator: You don't have enough money to pay for this call!");
                        ErrorMsg(playerid,"Hangup!");
                    }
                    else
                    {
                        GivePlayerMoney( playerid, -MAX_CALL_COST );
                        new str[64];
                        format(str,sizeof(str),"Call Cost: ~g~$~r~%i",Call_Cost);
                        GameTextForPlayer(playerid,str,3000,4);
                    }
                }
            }
        }
    }
    return 1;
}

dcmd_call(playerid, params[])
{
    new number;
    if (sscanf(params, "d", number))
    {
        UsageMsg(playerid, "USAGE: /call <Phone #>");
        HintMsg(playerid,"Available phone numbers: 112 (Emergency) 555 (Taxi)");
    }
    else if(number == 555)
    {
        if( GetPlayerMoney(playerid) < MAX_CALL_COST)
        {
            pCall[playerid] = 0;
            PhoneMsg(playerid,"Phone Operator: You don't have enough money to call!");
        }
        else if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
        {
            SetPlayerSpecialAction(playerid,SPECIAL_ACTION_USECELLPHONE);
            new str[64];
            format(str,sizeof(str),"Call Cost: ~r~%i$/min",MAX_CALL_COST);
            GameTextForPlayer(playerid,str,4000,4);
            GivePlayerMoney(playerid, -MAX_CALL_COST);
           
            //[SKIP] code that checks if there any taxi drivers... It works fine

            pCall[playerid] = 555;
            SystemMsg(playerid,"San Fierro Taxi Company");
            PhoneMsg(playerid,"Dispatch: Hello, please tell location to call taxi to.");           
        }
        else if(IsPlayerInAnyVehicle(playerid))
            ErrorMsg (playerid,"You cannot speak in a vehicle..");
        else ErrorMsg(playerid,"You can't call at the moment..");
    }
    return 1;
}

public OnPlayerText(playerid, text[])
{
    if(pCall[playerid]==555)
    {
        new name[24];
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(gTeam[i] == TEAM_TAXI)
            {
                //[SKIP] This works fine
            }
        }
        pCall[playerid]=0;
        return 0;
    }
}

if(strcmp(cmdtext,"/h",true)==0 || strcmp(cmdtext,"/hangup",true)==0)
{
  if( pCall[playerid] )
    {
    pCall[playerid] =0;
        SetPlayerSpecialAction(playerid,SPECIAL_ACTION_STOPUSECELLPHONE);
      SystemMsg( playerid, "You hang up.." );
    }

  return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)