/sms command help -
bosmania - 24.02.2019
i've got no ideea how to make this sms command work,please help,im new into this whole scripting thing.
CMD
ms(playerid,params[])
{
new message[128],string[128],string2[128],number,targetid;
foreach(Player, i)
{
number=PlayerInfo[i][pNumber];
}
if(PlayerInfo[playerid][pCellphone] == 0) return SendClientMessage(playerid, COLOR_GREY, "You don't own a phone");
if(PlayerInfo[playerid][pCellphoneOnline] == 0) return SendClientMessage(playerid, COLOR_GREY, " Your phone is turned off");
if(PlayerInfo[targetid][pCellphone] == 0) return SendClientMessage(playerid, COLOR_GREY, " That player does not have a phone");
if(PlayerInfo[targetid][pCellphoneOnline] == 0) return SendClientMessage(playerid, COLOR_GREY, "That player has his phone turned off");
if(sscanf(params,"is[128]", number,message)) return SendClientMessage(playerid, COLOR_RED, "USAGE:{ffffff}/sms <number> <message>");
if(targetid == playerid) return SendClientMessage(playerid, COLOR_GREY, "You can't send a message to yourself");
format(string,sizeof(string),"From %s:%s",GetName(playerid),message);
SendClientMessage(targetid, COLOR_YELLOW, string);
format(string2,sizeof(string2),"To %s:%s",GetName(targetid),message);
SendClientMessage(playerid, COLOR_GREY, string2);
return 1;
}
I know i have to do some stock function in order to save every player's phone number in a variable or so i've heard,i dont know so please help
Re: /sms command help -
bosmania - 24.02.2019
dDASD
Re: /sms command help -
TheToretto - 24.02.2019
Stock? What? No use a saving system such as MySQL Y_Ini etc... MySQL is highly recommended.
Re: /sms command help -
bosmania - 24.02.2019
and how exactly do i do that?
Re: /sms command help -
polygxn - 24.02.2019
You already have an enum for saving the numbers temporarily (PlayerInfo[playerid][pNumber]), you just need to save it to MySQL. There is plenty tutorials for it out there.
Re: /sms command help -
bosmania - 24.02.2019
I did save the number in mysql
case pNumberx: format(query, sizeof(query), "UPDATE `users` SET `Number`='%d' WHERE `ID`='%d'", PlayerInfo[playerid][pNumber], PlayerInfo[playerid][pID]);
PlayerInfo[playerid][pNumber] = cache_get_field_content_int(0, "Number", mysql);
but i dont know how to make the command work because when i enter the number when i use the sms command i get the message,it sends me the message no mather what number i type
Re: /sms command help -
bosmania - 24.02.2019
Can someone just look over the code and just correct it,that's it,how should it be written cause that's not correct,it's not working for me.
Re: /sms command help -
TheToretto - 24.02.2019
pawn Код:
foreach(Player, i)
{
number=PlayerInfo[i][pNumber];
}
This makes no sense, assigning value pNumber of the latest player connected, to the variable number.
pawn Код:
CMD:sms(playerid,params[])
{
new message[128], string[128], number;
if(PlayerInfo[playerid][pCellphone] == 0) return SendClientMessage(playerid, COLOR_GREY, "You don't own a phone");
if(PlayerInfo[playerid][pCellphoneOnline] == 0) return SendClientMessage(playerid, COLOR_GREY, " Your phone is turned off");
if(sscanf(params,"ds[128]", number, message)) return SendClientMessage(playerid, COLOR_RED, "USAGE:{ffffff}/sms <number> <message>");
if(number == PlayerInfo[playerid][pNumber]) return SendClientMessage(playerid, COLOR_GREY, "You can't send a message to yourself");
foreach(new i : Player)
{
if(PlayerInfo[i][pNumber] != number) continue;
if(PlayerInfo[i][pCellphone] == 0)
return SendClientMessage(playerid, COLOR_GREY, " That player does not have a phone");
if(PlayerInfo[i][pCellphoneOnline] == 0)
return SendClientMessage(playerid, COLOR_GREY, "That player has his phone turned off");
format(string, sizeof(string), "From %s:%s", GetName(playerid), message);
SendClientMessage(i, COLOR_YELLOW, string);
format(string, sizeof(string), "To %s:%s", GetName(i), message);
SendClientMessage(playerid, COLOR_GREY, string);
}
return 1;
}
Re: /sms command help -
bosmania - 24.02.2019
Thanks a lot man,i didn't know how to write that foreach (new i : player) part.