[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


Messages In This Thread
Making Goto With ZCMD And Sscanf - by dh240473 - 22.02.2015, 05:50
Re: Making Goto With ZCMD And Sscanf - by CalvinC - 22.02.2015, 06:35
Re: Making Goto With ZCMD And Sscanf - by dh240473 - 22.02.2015, 07:31

Forum Jump:


Users browsing this thread: 1 Guest(s)