SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 01/07/2020, 06:17 AM   #1
_GHT_MarK445
Huge Clucker
 
Join Date: Oct 2010
Posts: 283
Reputation: 5
Default SCMTA not displaying

Hi guys,

I have this piece of code, but the problem is, that the message (SCMTA) is not showing. I tried to put a sound after displaying the message, to determine, where is the problem, but the sound was playet to the target, so it has to be something with the message, however I do not see anything wrong with it. Every conditions are working, but when everything is fullfilled, the message just does not display.

Code:
CMD:s(playerid, params[])
{
    new id, language, string[256];
    if(sscanf(params,"ii", id, type)) return SendClientMessage(playerid, yellow,"/s <id> <0 or 1>");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, yellow,"Player is not connected");
    if(id == playerid) return SendClientMessage(playerid, yellow,"You can not welcome yourself.");
    if(type == 0)
    {
		format(string, sizeof(string), "%s(%d): Hi %s, if you need anything, feel free to ask me.", GetName(playerid), playerid, GetName(id));
	}
	else if(type == 1)
	{
		format(string, sizeof(string), "%s(%d): Welcome on our server, %s!", GetName(playerid), playerid, GetName(id));
	}
	SendClientMessageToAll(GetPlayerColor(playerid), string);
	return 1;
}
For any help, I will be more, than just thankful.
_GHT_MarK445 is offline   Reply With Quote
Old 01/07/2020, 07:28 AM   #2
Sultanz
Little Clucker
 
Join Date: Jun 2019
Posts: 24
Reputation: 0
Default Re: SCMTA not displaying

Quote:
Originally Posted by _GHT_MarK445 View Post
Hi guys,

I have this piece of code, but the problem is, that the message (SCMTA) is not showing. I tried to put a sound after displaying the message, to determine, where is the problem, but the sound was playet to the target, so it has to be something with the message, however I do not see anything wrong with it. Every conditions are working, but when everything is fullfilled, the message just does not display.

Code:
CMD:s(playerid, params[])
{
    new id, language, string[256];
    if(sscanf(params,"ii", id, type)) return SendClientMessage(playerid, yellow,"/s <id> <0 or 1>");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, yellow,"Player is not connected");
    if(id == playerid) return SendClientMessage(playerid, yellow,"You can not welcome yourself.");
    if(type == 0)
    {
		format(string, sizeof(string), "%s(%d): Hi %s, if you need anything, feel free to ask me.", GetName(playerid), playerid, GetName(id));
	}
	else if(type == 1)
	{
		format(string, sizeof(string), "%s(%d): Welcome on our server, %s!", GetName(playerid), playerid, GetName(id));
	}
	SendClientMessageToAll(GetPlayerColor(playerid), string);
	return 1;
}
For any help, I will be more, than just thankful.
I tested this code just now and it works, I can see the SendClientMessageToAll(I tested it with myself only by removing the target == playerid check)

How come you didn't get any warning in the sscanf if statement? You didn't declare the variable 'type' (Or did you declare it somewhere else?), Also that 'language' variable is un-used. Also, since you want the input for 'type' to be only 0-1, You should add these checks:

Code:
if(!IsNumber(type)) return SendClientMessage(playerid, -1, "Input must be numeric only");
if(type > 1 | 0 < type) return SendClientMessage(playerid, -1, "Type can only be 0/1");
IsNumber function(I didn't make this):
Code:
stock IsNumeric(const str[ ])
{
    new len = strlen(str);

    if (!len) return false;
    for(new i; i < len; i++)
    {
        if (!('0' <= str[i] <= '9')) return false;
    }
    return true;
}
Sultanz is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Strings not displaying Luke_James Scripting Help 5 18/08/2015 02:15 PM
Not displaying suni Scripting Help 5 04/06/2015 06:12 PM
Displaying map Ihsan_Cingisiz Help Archive 1 05/06/2010 05:53 PM
Displaying More Ad's master000 Help Archive 2 13/03/2010 06:24 PM


All times are GMT. The time now is 04:13 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.