[Tutorial] Making Goto With ZCMD And Sscanf
#1

First Of All Put Include Zcmd And sscanf On Top Script :
Quote:
#include <zcmd>
#include <sscanf2>
Then Second Thing Is Making Goto Command :
Quote:

CMD:goto(playerid, params[])
{
return 1;
}

Now Let Make The Function
Quote:

new pID;
if(sscanf(params, "u", pID)) return SendClientMessage(playerid, -1, "/Goto [Playerid]");

"u" = for playerid
"d" = for number
"s" = for word
"f" = for float
Quote:

if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, -1, "Player Is Not Connected!")

"!" = Mean Not
If You Delete ! It Mean IsPlayerConnected If You Put ! It Mean If Player Not Connected
Quote:

if(pID == playerid) return 0;

It Mean If You're Trying To Use The Command To Your Self It Will Be Nothing
Quote:

new Float: x, Float:y, Float:z;
GetPlayerPos(pID, x, y, z);

To Get Player Position
Quote:

if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SetVehiclePos(GetPlayerVehicleID(playerid), x+2, y, z);
LinkVehicleToInterior(GetPlayerVehicleID(playerid) , 0);
SetCameraBehindPlayer(playerid);
}

If You Want Car Also Can Follow The Player
Then Put Else If Without Car
Quote:

else
{
SetPlayerPos(playerid, x+2, y, z); SetCameraBehindPlayer(playerid);
}

Then Put return 1; for close the function
Quote:

return 1;
}

Ok Done
Full Command
Quote:

CMD:goto(playerid, params[])
{
new pID;
if(sscanf(params, "u", pID)) return SendClientMessage(playerid, -1, "/Goto [Playerid]");
if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, -1, "That user is not connected.");
if(pID == playerid) return 0;
new Float: x, Float:y, Float:z;
GetPlayerPos(pID, x, y, z);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SetVehiclePos(GetPlayerVehicleID(playerid), x+2, y, z);
LinkVehicleToInterior(GetPlayerVehicleID(playerid) , 0);
SetCameraBehindPlayer(playerid);
}
else
{
SetPlayerPos(playerid, x+2, y, z); SetCameraBehindPlayer(playerid); }
return 1;
}

Reply
#2

Quote:

"u" = for playerid
"d" = for number
"s" = for word
"f" = for float

"d" and "i" is called an integer, they can both be used, if i remember right it's like a number without a decimal.
"s" means a string, which can have all sorts of characters in it.

Код:
if(pID == playerid) return 0;
Why return 0? It'll give the "Unknown command" message.

Код:
LinkVehicleToInterior(GetPlayerVehicleID(playerid) , 0);
If the other player is in an interior, you should use GetPlayerInterior instead of 0.

Also, you don't explain that much, but you do however explain some things, so that's good.
Reply
#3

I Newbie Thx I Will Try It
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)