Guest User

Cellphone issue

a guest
May 13th, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.80 KB | None | 0 0
  1. //Hangup
  2. CMD:hangup(playerid, params[])
  3. {
  4.     new string[128];
  5.     if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  6.     if(!PlayerInfo[playerid][pHasCellphone]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a cellphone.");
  7.     if(!BeingCalled[playerid] && !Calling[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on a call nor is anybody calling you.");
  8.     format(string, sizeof(string), "* %s puts their cellphone away.", RPN(playerid));
  9.     SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  10.     SendClientMessage(playerid, COLOR_ORANGE, " You have hungup the line.");
  11.     if(BeingCalled[playerid]) SendClientMessage(Caller[playerid], COLOR_ORANGE, " They hungup the line.");
  12.     else if(Calling[playerid]) SendClientMessage(Called[playerid], COLOR_ORANGE, " They hungup the line.");
  13.     if(Call911[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You can't hangup on a 911 call.");
  14.     //
  15.     SetPlayerSpecialAction(playerid, SPECIAL_ACTION_STOPUSECELLPHONE);
  16.     if(Calling[playerid])
  17.     {
  18.         SetPlayerSpecialAction(Called[playerid], SPECIAL_ACTION_STOPUSECELLPHONE);
  19.         format(string, sizeof(string), "[Cellphone] Phonecall lasted for %d seconds, price: $%d", CallTime[playerid], CallTime[playerid]*10/100);
  20.         SendClientMessage(playerid, COLOR_YELLOW, string);
  21.         GiveZaiatMoney(playerid, -(CallTime[playerid]*10/100));
  22.         TaxMoney += (CallTime[playerid]*10/100);
  23.         Calling[playerid] = 0;
  24.         BeingCalled[playerid] = 0;
  25.         Caller[playerid] = -1;
  26.         CallTime[playerid] = 0;
  27.         Called[playerid] = -1;
  28.     }
  29.     else if(Calling[Caller[playerid]])
  30.     {
  31.         SetPlayerSpecialAction(Called[playerid], SPECIAL_ACTION_STOPUSECELLPHONE);
  32.         format(string, sizeof(string), "[Cellphone] Phonecall lasted for %d seconds, price: $%d", CallTime[Caller[playerid]], CallTime[Caller[playerid]]*10/100);
  33.         SendClientMessage(Caller[playerid], COLOR_YELLOW, string);
  34.         GiveZaiatMoney(Caller[playerid], -(CallTime[Caller[playerid]]*10/100));
  35.         TaxMoney += (CallTime[Caller[playerid]]*10/100);
  36.         Calling[Called[playerid]] = 0;
  37.         BeingCalled[Called[playerid]] = 0;
  38.         Caller[Called[playerid]] = -1;
  39.         CallTime[Called[playerid]] = 0;
  40.         Called[Called[playerid]] = -1;
  41.     }
  42.     return 1;
  43. }
  44.  
  45.  
  46.  
  47. //Call
  48. CMD:call(playerid, params[])
  49. {
  50.     new number, string[128], done;
  51.     if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  52.     if(!PlayerInfo[playerid][pHasCellphone]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a cellphone.");
  53.     if(!PlayerInfo[playerid][pCellphone]) return SendClientMessage(playerid, COLOR_GREY, "You don't have a simcard.");
  54.     if(sscanf(params, "i", number)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /call [number]");
  55.     if(PhoneOff[playerid]) return SendClientMessage(playerid, COLOR_GREY, "Your phone is turned off.");
  56.     if(Calling[playerid] || BeingCalled[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are already on a call.");
  57.     if(number == 0) return SendClientMessage(playerid, COLOR_GREY, "Invalid phone number.");
  58.     format(string, sizeof(string), "* %s takes out their cellphone and starts calling a number.", RPN(playerid));
  59.     SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  60.     if(number == 911)
  61.     {
  62.         Calling[playerid] = 1;
  63.         Call911[playerid] = 1;
  64.         SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
  65.         SendClientMessage(playerid, COLOR_YELLOW, "[Cellphone]: You are connected to the SAPD emergency line, please explain your emergency.");
  66.     }
  67.     foreach(Player, i)
  68.     {
  69.         if(PlayerInfo[i][pCellphone] == number)
  70.         {
  71.             if(PhoneOff[i]) return SendClientMessage(playerid, COLOR_GREY, "Player has their phone turned off.");
  72.             if(BeingCalled[i] || Calling[i]) return SendClientMessage(playerid, COLOR_GREY, "Number busy.");
  73.             Calling[playerid] = 1;
  74.             BeingCalled[i] = 1;
  75.             Called[playerid] = i;
  76.             Caller[i] = playerid;
  77.             SendClientMessage(playerid, COLOR_ORANGE, " The cellphone is ringing, wait for someone to pickup.");
  78.             format(string, sizeof(string), "* %s's cellphone starts ringing.", RPN(i));
  79.             SendNearbyMessage(i, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  80.             format(string, sizeof(string), " [Cellphone]: Incoming call from %s, Ph: %d", RPN(playerid), PlayerInfo[playerid][pCellphone]);
  81.             SendClientMessage(i, COLOR_YELLOW, string);
  82.             SendClientMessage(i, COLOR_WHITE, " Type /pickup to answer or /hangup to cancel the incoming call.");
  83.             done = 1;
  84.             SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
  85.         }
  86.     }
  87.     if(done != 1)
  88.     {
  89.         SendClientMessage(playerid, COLOR_GREY, "Number is not currently available.");
  90.     }
  91.     return 1;
  92. }
  93.  
  94.  
  95. //Pickup
  96. CMD:pickup(playerid, params[])
  97. {
  98.     new string[128];
  99.     if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
  100.     if(!PlayerInfo[playerid][pHasCellphone]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a cellphone.");
  101.     if(!BeingCalled[playerid]) return SendClientMessage(playerid, COLOR_GREY, "Nobody is caling you.");
  102.     format(string, sizeof(string), "* %s answers their cellphone.", RPN(playerid));
  103.     SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
  104.     SendClientMessage(playerid, COLOR_ORANGE, " You have picked up the line.");
  105.     SendClientMessage(Caller[playerid], COLOR_ORANGE, " They pickedup the line.");
  106.     Calling[Caller[playerid]] = 2;
  107.     BeingCalled[playerid] = 2;
  108.     SetTimerEx("PhoneCall", 1000, false, "d", Caller[playerid]);
  109.     return 1;
  110. }
Advertisement
Add Comment
Please, Sign In to add comment