SA-MP Forums Archive
dcmd not work - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: dcmd not work (/showthread.php?tid=157605)



dcmd not work - iJumbo - 07.07.2010

what wrong here??
pawn Код:
dcmd_tele(playerid, params[])
{
    new cordx,cordy,cordz;
    if(sscanf(params, "ud",cordx,cordy,cordz)) return SendClientMessage(playerid,0xFF0000FF, "[aiuto]: /tele[x][y][z]");
    SendClientMessage(playerid,0xFF9900AA,"coord=%d %d %d",cordx,cordy,cordz);
    return SetPlayerPos(playerid,cordx,cordy,cordz);
}



Re: dcmd not work - Miikkel - 07.07.2010

Did you add
pawn Код:
dcmd(tele, 4, cmdtext);
Under OnPlayerCommandText ?

EDIT:

Alse you might want to create a string for the "SendClientMessage". Like this:
pawn Код:
new String[256];
format(String, sizeof(String), "cord= %s, %s, %s.", cordx, cordy, cordz);
SendClientMessage(playerid, Color, String);



Re: dcmd not work - dice7 - 07.07.2010

Format the string before sending it
https://sampwiki.blast.hk/wiki/Format


Re: dcmd not work - iJumbo - 07.07.2010

okay i make this
pawn Код:
dcmd_teleporto(playerid, params[])
{
    new cordx,cordy,cordz;
    new text[128];
    if(sscanf(params, "ud",cordx,cordy,cordz)) return SendClientMessage(playerid,0xFF0000FF, "[aiuto]: /teleporto [x][y][z]");
    format(text,sizeof(text),"[cord]: %d %d %d",cordx,cordy,cordz);
    SendClientMessage(playerid,0xFF9900AA,text);
    return SetPlayerPos(playerid,cordx,cordy,cordz);
}
but dont teleport me


Re: dcmd not work - WackoX - 07.07.2010

Why are you using "ud" as string in sscanf?
You're using 3 decimals now so you have to do "ddd".


Re: dcmd not work - dice7 - 07.07.2010

Coordinates are floats and you need to change the data type definition in sscanf to fff, which represents 3 floats (x, y, z). But you can still use integers, since nobodys gonna bother typing floats in a command


Re: dcmd not work - WackoX - 07.07.2010

Код:
dcmd_teleporto(playerid, params[])
{
    	new Float:cordx, Float:cordy, Float:cordz;
    	if(sscanf(params, "fff",cordx, cordy, cordz)) 
		return SendClientMessage(playerid, 0xFF0000FF, "[aiuto]: /teleporto [x][y][z]");

	new string[64];
    	format(text, sizeof(text), "[cord]: %.4f %.4f %.4f",cordx, cordy, cordz);
    	SendClientMessage(playerid, 0xFF9900AA, text);
	SetPlayerPos(playerid, cordx, cordy, cordz);
	return 1;
}
I can't understand how you even compiled the previous code.


Re: dcmd not work - iJumbo - 07.07.2010

omg i typed /teleporto 281.1523 2527.4270 16.8029 and teleport me to 1132341 2424124 46616166 wtF?


Re: dcmd not work - WackoX - 07.07.2010

Quote:
Originally Posted by WackoX
Посмотреть сообщение
Код:
dcmd_teleporto(playerid, params[])
{
    	new Float:cordx, Float:cordy, Float:cordz;
    	if(sscanf(params, "fff",cordx, cordy, cordz)) 
		return SendClientMessage(playerid, 0xFF0000FF, "[aiuto]: /teleporto [x][y][z]");

	new string[64];
    	format(text, sizeof(text), "[cord]: %.4f %.4f %.4f",cordx, cordy, cordz);
    	SendClientMessage(playerid, 0xFF9900AA, text);
	SetPlayerPos(playerid, cordx, cordy, cordz);
	return 1;
}
I can't understand how you even compiled the previous code.
Like i said.


Re: dcmd not work - iJumbo - 07.07.2010

yea thx now work fine