SA-MP Forums Archive
SMS not working | Only ID 0 can send/receive texts - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: SMS not working | Only ID 0 can send/receive texts (/showthread.php?tid=629870)



SMS not working | Only ID 0 can send/receive texts - oSAINTo - 05.03.2017

Код:
CMD:sms(playerid, params[])
{
    new string[126], smstext[126], tnum;
    if(PlayerInfo[playerid][pPhone] == 0) return SCM(playerid, COLOR_LIGHTRED, "You don't have a phone.");
    if(sscanf(params, "is[126]", tnum, smstext))
	{
		SendClientMessage(playerid, COLOR_LIGHTRED, "USAGE: {FFFFFF} /sms [number] [input]");
	}
    else
	{
	    format(string, sizeof(string), "* %s slips out their phone and compiles a text message.", GetName(playerid));
		ProxDetector(30.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
		new sender = PlayerInfo[playerid][pNumber];
  		for(new i = 0; i <= MAX_PLAYERS; i++)
		{
  			if(IsPlayerConnected(i))
  			{
				if(PlayerInfo[i][pNumber] == tnum)
				{
					if(onoff[i] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "The number you entered may not exist or the device is turned off.");
					format(string, sizeof(string), "( [SMS:] %s, Sender: [%d] )", smstext, sender);
					SendClientMessage(i, COLOR_YELLOW, string);
				}
				return 1;
			}
			else
			{
			    SendClientMessage(playerid, COLOR_LIGHTRED, "Text message delivery has failed.");
				return 1;
			}
		}
	}
	return 1;
}
Any help would be appreciated, the bug is in the title.


Re: SMS not working | Only ID 0 can send/receive texts - JessThompson - 05.03.2017

Код:
CMD:sms(playerid, params[])
{
    new string[126], smstext[126], tnum;
    if(PlayerInfo[playerid][pPhone] == 0) return SCM(playerid, COLOR_LIGHTRED, "You don't have a phone.");
    if(sscanf(params, "is[126]", tnum, smstext))
	{
		SendClientMessage(playerid, COLOR_LIGHTRED, "USAGE: {FFFFFF} /sms [number] [input]");
	}
    else
	{
	    format(string, sizeof(string), "* %s slips out their phone and compiles a text message.", GetName(playerid));
		ProxDetector(30.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
		new sender = PlayerInfo[playerid][pNumber];
  		for(new i = 0; i < MAX_PLAYERS; i++)
		{
  			if(IsPlayerConnected(i))
  			{
				if(PlayerInfo[i][pNumber] == tnum)
				{
					if(onoff[i] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "The number you entered may not exist or the device is turned off.");
					format(string, sizeof(string), "( [SMS:] %s, Sender: [%d] )", smstext, sender);
					SendClientMessage(i, COLOR_YELLOW, string);
				}
				return 1;
			}
			else
			{
			    SendClientMessage(playerid, COLOR_LIGHTRED, "Text message delivery has failed.");
				return 1;
			}
		}
	}
	return 1;
}
Try this for me please :P


Re: SMS not working | Only ID 0 can send/receive texts - oSAINTo - 05.03.2017

Quote:
Originally Posted by JessThompson
Посмотреть сообщение
Код:
CMD:sms(playerid, params[])
{
    new string[126], smstext[126], tnum;
    if(PlayerInfo[playerid][pPhone] == 0) return SCM(playerid, COLOR_LIGHTRED, "You don't have a phone.");
    if(sscanf(params, "is[126]", tnum, smstext))
	{
		SendClientMessage(playerid, COLOR_LIGHTRED, "USAGE: {FFFFFF} /sms [number] [input]");
	}
    else
	{
	    format(string, sizeof(string), "* %s slips out their phone and compiles a text message.", GetName(playerid));
		ProxDetector(30.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
		new sender = PlayerInfo[playerid][pNumber];
  		for(new i = 0; i < MAX_PLAYERS; i++)
		{
  			if(IsPlayerConnected(i))
  			{
				if(PlayerInfo[i][pNumber] == tnum)
				{
					if(onoff[i] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "The number you entered may not exist or the device is turned off.");
					format(string, sizeof(string), "( [SMS:] %s, Sender: [%d] )", smstext, sender);
					SendClientMessage(i, COLOR_YELLOW, string);
				}
				return 1;
			}
			else
			{
			    SendClientMessage(playerid, COLOR_LIGHTRED, "Text message delivery has failed.");
				return 1;
			}
		}
	}
	return 1;
}
Try this for me please :P
Now ID 0 can receive texts but he can't send them( other players can't receive or send them.)


Re: SMS not working | Only ID 0 can send/receive texts - JessThompson - 05.03.2017

Does it show a error when you try to send them a text?


Re: SMS not working | Only ID 0 can send/receive texts - oSAINTo - 05.03.2017

Quote:
Originally Posted by JessThompson
Посмотреть сообщение
Does it show a error when you try to send them a text?
nope.


Re: SMS not working | Only ID 0 can send/receive texts - JessThompson - 05.03.2017

Код:
CMD:sms(playerid, params[])
{
    new string[126], smstext[126], tnum;
    if(PlayerInfo[playerid][pPhone] == 0) return SCM(playerid, COLOR_LIGHTRED, "You don't have a phone.");
    if(sscanf(params, "is[126]", tnum, smstext))
	{
		SendClientMessage(playerid, COLOR_LIGHTRED, "USAGE: {FFFFFF} /sms [number] [input]");
	}
    else
	{
	    format(string, sizeof(string), "* %s slips out their phone and compiles a text message.", GetName(playerid));
		ProxDetector(30.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
		new sender = PlayerInfo[playerid][pNumber];
  		for(new i = 0; i < MAX_PLAYERS; i++)
		{
  			if(IsPlayerConnected(i))
  			{
				if(PlayerInfo[i][pNumber] == tnum)
				{
					if(onoff[i] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "The number you entered may not exist or the device is turned off.");
					format(string, sizeof(string), "( [SMS:] %s, Sender: [%d] )", smstext, sender);
					SendClientMessage(i, COLOR_YELLOW, string);
				}
			}
			else
			{
			    SendClientMessage(playerid, COLOR_LIGHTRED, "Text message delivery has failed.");
				return 1;
			}
		}
	}
	return 1;
}
Try this again please


Re: SMS not working | Only ID 0 can send/receive texts - oSAINTo - 05.03.2017

Quote:
Originally Posted by JessThompson
Посмотреть сообщение
Код:
CMD:sms(playerid, params[])
{
    new string[126], smstext[126], tnum;
    if(PlayerInfo[playerid][pPhone] == 0) return SCM(playerid, COLOR_LIGHTRED, "You don't have a phone.");
    if(sscanf(params, "is[126]", tnum, smstext))
	{
		SendClientMessage(playerid, COLOR_LIGHTRED, "USAGE: {FFFFFF} /sms [number] [input]");
	}
    else
	{
	    format(string, sizeof(string), "* %s slips out their phone and compiles a text message.", GetName(playerid));
		ProxDetector(30.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
		new sender = PlayerInfo[playerid][pNumber];
  		for(new i = 0; i < MAX_PLAYERS; i++)
		{
  			if(IsPlayerConnected(i))
  			{
				if(PlayerInfo[i][pNumber] == tnum)
				{
					if(onoff[i] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "The number you entered may not exist or the device is turned off.");
					format(string, sizeof(string), "( [SMS:] %s, Sender: [%d] )", smstext, sender);
					SendClientMessage(i, COLOR_YELLOW, string);
				}
			}
			else
			{
			    SendClientMessage(playerid, COLOR_LIGHTRED, "Text message delivery has failed.");
				return 1;
			}
		}
	}
	return 1;
}
Try this again please
That worked, thank you so much. +Rep


Re: SMS not working | Only ID 0 can send/receive texts - JessThompson - 05.03.2017

No problem :P