Problem with making /tp and /say Command
#1

Ive been working on a simple gamemode, Ive only been scripting for under 24hrs now.
Ive been shown ZCMD which is great.
But i cant seem to get two commands to work:
When i type "/tp 0" to Spawn to player 0 it should say "Spawning to Player_name"
but it just says "Spawning to 0"

CMD:tp(playerid,params[])
{
if (isnull(params)) {
SendClientMessage(playerid, COLOR_LIGHTBLUE1, "Usage: /tp [playerid]");
return 1;
}
else {
if (IsPlayerConnected(params[1])) {
new Float:X, Float:Y, Float:Z;
GetPlayerPos(params[0],X,Y,Z);
SetPlayerPos(playerid,X,Y,Z);

new name[128];
new string[128];
GetPlayerName(params[0],name, sizeof(name));
format(string, sizeof(string), "Spawning to %i", name);
SendClientMessage(playerid, COLOR_LIGHTBLUE1, string);
return 1;
}
else {
SendClientMessage(playerid, COLOR_LIGHTBLUE1, "No such user online.");
return 1;
}
}
}

Ive tried to make a /say command but instead of outputting the text entered in params[0] it just
outputs a number.
e.g. "/say Hello" Outputs "[Server]: 72"

CMDay(playerid,params[0])
{
if (isnull(params)) {
SendClientMessage(playerid, COLOR_LIGHTBLUE1, "Usage: /say [text]");
return 1;
}
else {
new string[128];
format(string, sizeof(string), "[SERVER]: %i", params[0]);
SendClientMessageToAll(0xFF9900AA, string);
return 1;
}
}

What have i done wrong?
Reply
#2

Quote:
Originally Posted by ******
Посмотреть сообщение
"name" is a string, so you need to use "%s", not "%d".
Thanks!
Thats Sorted /say perfectly
Reply
#3

TP Is still not working after a quick tweak all it now says is
No Such User Online
I currently have:
Код:
CMD:tp(playerid,params[])
{
	if (isnull(params)) {
		SendClientMessage(playerid, COLOR_LIGHTBLUE1, "Usage: /tp [playerid]");
		return 1;
	}
	else {
		if (IsPlayerConnected(params[0])) {
			new Float:X, Float:Y, Float:Z;
    		GetPlayerPos(params[0],X,Y,Z);
			SetPlayerPos(playerid,X,Y,Z);

			new name[128];
			new string[128];
			GetPlayerName(params[0],name, sizeof(name));
    		format(string, sizeof(string), "Spawning to %s", name);
    		SendClientMessage(playerid, COLOR_LIGHTBLUE1, string);
			return 1;
		}
		else {
			SendClientMessage(playerid, COLOR_LIGHTBLUE1, "No such user online.");
			return 1;
		}
	}
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)