Public feed #888890

Anonymous

public text v1 · immutable
Raw Edit
·published 2008-02-02 14:34 UTC
rendered paste body
if(strcmp(cmd, "/call", true) == 0)
		{
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp)) {
			SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /call [playerid]");
			return 1;
		}
		giveplayerid = strval(tmp);

		if (logged[playerid] != 1)
		{
		    SendClientMessage(playerid, COLOR_BRIGHTRED, "You must be logged in to make a phone call!");
			return 1;
		}
		if (GetPlayerMoney(playerid) < CallCost)
		{
			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;
		    return 1;
	}
	if(strcmp(cmd, "/answer", true) == 0)
		{
		if (logged[playerid] != 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;
		    return 1;
	}
	if(strcmp(cmd, "/hangup", true) == 0)
		{
		if (logged[playerid] != 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;
		}
		    return 1;
	}
	return 0;
}