20.01.2012, 16:09
pawn Код:
CMD:sms(playerid, params[])
{
if(PlayerInfo[playerid][Phone] == phone_yes)
{
if(phoneon[playerid] == false) return SendClientMessage(playerid, COLOR_GREY, "You have your phone turned off!");
new text[128], pnumber;
if(sscanf(params, "is[128]", pnumber, text)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /sms [Phone Number] [SMS text]");
new pID, count=0; //Lets create a variable to store who has the phone number
foreach(Player, i)
{
if(PlayerInfo[i][Phone] == phone_yes)
{
if(PlayerInfo[i][PhoneNumber] == pnumber)
{
i = pID; //We check who has it, then we save them into pID
count++;
}
}
}
if(count == 0) return SendClientMessage(playerid, COLOR_GREY, "Phone number not found!");
if(pID != playerid) //Check if the one who has it is the same person who typed the command
{
if(phoneon[pID] == false) return SendClientMessage(playerid, COLOR_GREY, "This player has their phone turned off!"); //their = possesive him/her
new string[265], pnumber2;
pnumber2 = PlayerInfo[playerid][PhoneNumber];
format(string, sizeof(string), "[SMS]%i: %s.", pnumber2, text);
SendClientMessage(pID, TEAM_RADIO_COLOR, string);
format(string, sizeof(string), "You've sent a text message to %i", pnumber); //We can format the same string twice instead of creating a new one
SendClientMessage(playerid, TEAM_RADIO_COLOR, string2);
PlayerPlaySound(pID,1085,0.0,0.0,0.0);
return 1;
}
}
else return SendClientMessage(playerid, COLOR_GREY, "You don't have a phone!");
return 1;
}