CMD:call(playerid,params[]) {
new giveplayerid,string[128],giveplayer[MAX_PLAYER_NAME],sendername[MAX_PLAYER_NAME];
if (sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "USAGE: /call <ID>");
// if (!IsNumeric(giveplayerid)) giveplayerid = ReturnPlayerID(giveplayerid);
if (PlayerInfo[playerid][LoggedIn] != 1)
{
SendClientMessage(playerid, COLOR_BRIGHTRED, "You must be logged in to make a phone call!");
return 1;
}
if (GetPlayerMoney(playerid) < CALL_UNIT_COST)
{
SendClientMessage(playerid, COLOR_BRIGHTRED, "You do not have enough money to make a phone call!");
return 1;
}
if (giveplayerid == playerid)
{
SendClientMessage(playerid, COLOR_BRIGHTRED, "You cannot call yourself!");
return 1;
}
if (!(IsPlayerConnected(giveplayerid)))
{
SendClientMessage(playerid, COLOR_BRIGHTRED, "Inactive player id!");
return 1;
}
if (Calling[playerid] > -1)
{
GetPlayerName(Calling[playerid], giveplayer, sizeof(giveplayer));
format(string, sizeof(string), "You are already on the phone to %s!", giveplayer);
SendClientMessage(playerid, COLOR_BRIGHTRED, string);
return 1;
}
if (Calling[giveplayerid] > -1)
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
format(string, sizeof(string), "%s is already on the phone, try again later", giveplayer);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
return 1;
}
else
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s is ringing you, type /answer to answer the call or /hangup to ignore it", sendername);
SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "You are ringing %s", giveplayer);
SendClientMessage(playerid, COLOR_GREEN, string);
Calling[playerid] = giveplayerid;
Calling[giveplayerid] = playerid;
Callerid[playerid] = 1;
SetPlayerSpecialAction(playerid,SPECIAL_ACTION_USECELLPHONE);
}
return 1;
}
//---------------------------------Answer Phone---------------------------------
CMD:answer(playerid,params[]) {
new string[128],giveplayer[MAX_PLAYER_NAME],sendername[MAX_PLAYER_NAME];
if (PlayerInfo[playerid][LoggedIn] != 1)
{
SendClientMessage(playerid, COLOR_BRIGHTRED, "You must be logged in to answer a phone call!");
return 1;
}
if (Calling[playerid] == -1)
{
SendClientMessage(playerid, COLOR_BRIGHTRED, "Nobody is calling you!");
return 1;
}
if (Answered[playerid] == 1)
{
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You are already on the phone!");
return 1;
}
else
{
GetPlayerName(Calling[playerid], giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s has answered your call, talk away", sendername);
SendClientMessage(Calling[playerid], COLOR_GREEN, string);
format(string, sizeof(string), "You have answered %s's call, talk away", giveplayer);
SendClientMessage(playerid, COLOR_GREEN, string);
Answered[playerid] = 1;
Answered[Calling[playerid]] = 1;
Callerid[Calling[playerid]] = 1;
SetPlayerSpecialAction(playerid,SPECIAL_ACTION_USECELLPHONE);
}
return 1;
}
//---------------------------------HangUp Phone---------------------------------
CMD:hangup(playerid,params[]) {
new string[128],giveplayer[MAX_PLAYER_NAME],sendername[MAX_PLAYER_NAME];
if (PlayerInfo[playerid][LoggedIn] != 1)
{
SendClientMessage(playerid, COLOR_BRIGHTRED, "You must be logged in to hang up a phone call!");
return 1;
}
if (Calling[playerid] == -1)
{
SendClientMessage(playerid, COLOR_BRIGHTRED, "You are not on the phone!");
return 1;
}
else
{
GetPlayerName(Calling[playerid], giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s has hung up the phone on you", sendername);
SendClientMessage(Calling[playerid], COLOR_LIGHTBLUE, string);
format(string, sizeof(string), "You have hung up on %s", giveplayer);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
new bCalling = Calling[playerid];
Calling[playerid] = -1;
Answered[playerid] = 0;
Callerid[playerid] = 0;
Calling[bCalling] = -1;
Answered[bCalling] = 0;
Callerid[bCalling] = 0;
SetPlayerSpecialAction(Calling[playerid],SPECIAL_ACTION_STOPUSECELLPHONE);
SetPlayerSpecialAction(playerid,SPECIAL_ACTION_STOPUSECELLPHONE);
}
return 1;
}
//=================================Phone stuff==================================
public PhoneCut(playerid)
{
for (new i = 0; i < GetMaxPlayers(); i++)
{
if (Calling[i] > -1 && Answered[i] == 1 && Callerid[i] == 1)
{
if (GetPlayerMoney(i) >= CALL_UNIT_COST)
{
GivePlayerMoney(i, -CALL_UNIT_COST);
}
if (GetPlayerMoney(i) < CALL_UNIT_COST)
{
SendClientMessage(i, COLOR_BRIGHTRED, "CUT OFF: You don't have enough cash to continue this call");
SendClientMessage(Calling[i], COLOR_BRIGHTRED, "CUT OFF: Your recipient's phone has been cut off due to lack of credit");
SetPlayerSpecialAction(playerid,SPECIAL_ACTION_STOPUSECELLPHONE);
Calling[Calling[i]] = -1;
Answered[Calling[i]] = 0;
Calling[i] = -1;
Answered[i] = 0;
Callerid[i] = 0;
}
}
}
return 1;
}
forward HighLight(playerid);
public HighLight(playerid)
{
if(PlayerInfo[playerid][blipS] == 0) { SetPlayerColor(playerid, 0xFF0000AA); PlayerInfo[playerid][blipS] = 1; }
else { SetPlayerColor(playerid, 0x33FF33AA); PlayerInfo[playerid][blipS] = 0; }
return 0;
}
if(ServerInfo[ReadPMs] == 1 && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel])
{
new string[128],recievername[MAX_PLAYER_NAME];
GetPlayerName(playerid, string, sizeof(string)); GetPlayerName(id, recievername, sizeof(recievername));
format(string, sizeof(string), "***PM: %s To %s: %s", string, recievername, gMessage);
for (new a = 0; a < MAX_PLAYERS; a++) if ((PlayerInfo[a][Level] >= ServerInfo[MaxAdminLevel]) && a != playerid)
SendClientMessage(a, grey, string);
}
yeah but that will not allow me to read what they type in cellphone conversation!!
|