Move cmd help -
SnG.Scot_MisCuDI - 25.12.2011
i have a cmd where you do /up, /down, /left, /right. The defualt for up is 50 and the rest is 10. How can i make it so you do /up (amount) /down (amount) left right (amount)
pawn Код:
if (strcmp("/up", cmdtext, true, 8 ) == 0)
{
new Float:X, Float:Y, Float:Z;
new vehicleid = GetPlayerVehicleID(playerid);
GetPlayerPos(playerid, X, Y, Z);
if(IsPlayerInAnyVehicle(playerid)) {
SetVehiclePos(vehicleid, X, Y, Z+50);
SendClientMessage(playerid,COL_ADMIN,"** Moved up 50 feet.");
}
else {
SetPlayerPos(playerid,X, Y, Z+50);
SendClientMessage(playerid,COL_ADMIN,"** Moved up 50 feet.");
}
return 1;
}
Re: Move cmd help -
§с†¶e®РµРe - 25.12.2011
use sscanf2 by ******
Re: Move cmd help -
SnG.Scot_MisCuDI - 25.12.2011
I wouldnt know how to script it. If you can, can you make a zcmd ?
Re: Move cmd help -
Ballu Miaa - 25.12.2011
pawn Код:
if(strcmp(cmd, "/up", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] >= 1)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /up [amount]");
return 1;
}
new pos;
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
pos = strval(tmp);
new Float:X, Float:Y, Float:Z;
new vehicleid = GetPlayerVehicleID(playerid);
GetPlayerPos(playerid, X, Y, Z);
if(IsPlayerInAnyVehicle(playerid))
{
SetVehiclePos(vehicleid, X, Y, Z+pos);
SendClientMessage(playerid,COL_ADMIN,"** Moved up 50 feet.");
}
else
{
SetPlayerPos(vehicleid, X, Y, Z+pos);
SendClientMessage(playerid,COL_ADMIN,"** Moved up 50 feet.");
return 1;
}
}
else
{
SendClientMessage(playerid,COLOR_GRAD3,"You are not authorised to use this command.!");
return 1;
}
}
strcmp command by me the way you want. U can change it to zcmd if you want!
Re: Move cmd help -
SnG.Scot_MisCuDI - 25.12.2011
Too many errors. Can you change to zcmd for me
Re: Move cmd help -
Ballu Miaa - 25.12.2011
pawn Код:
CMD:up(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 1)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /up [amount]");
return 1;
}
new pos;
new sendername[MAX_PLAYER_NAME];
GetPlayerName(playerid, sendername, sizeof(sendername));
pos = strval(tmp);
new Float:X, Float:Y, Float:Z;
new vehicleid = GetPlayerVehicleID(playerid);
GetPlayerPos(playerid, X, Y, Z);
if(IsPlayerInAnyVehicle(playerid))
{
SetVehiclePos(vehicleid, X, Y, Z+pos);
SendClientMessage(playerid,COL_ADMIN,"** Moved up 50 feet.");
}
else
{
SetPlayerPos(vehicleid, X, Y, Z+pos);
SendClientMessage(playerid,COL_ADMIN,"** Moved up 50 feet.");
return 1;
}
}
else
{
SendClientMessage(playerid,COLOR_GRAD3,"You are not authorised to use this command.!");
return 1;
}
}
Only with strtok and zcmd ,sscanf2 not used! if you dont have strtok use #include <utils.inc> on the top of the GM.
Re: Move cmd help -
rinori - 25.12.2011
pawn Код:
CMD:up(playerid, params[])
{
new posup, Float:X, Float:Y, Float:Z;
if(sscaf(params, "d", posup)) return SendClientMessage(playerid, YOUR_COLOR, "Usage: /up [amount]");
else
{
GetPlayerPos(playerid, X, Y, Z);
if(IsPlayerInAnyVehicle(playerid))
{
SetVehiclePos(vehicleid, X, Y, Z+posup);
SendClientMessage(playerid,COL_ADMIN,"** Moved up 50 feet.");
}
else
{
SetPlayerPos(playerid,X, Y, Z+50);
SendClientMessage(playerid,COL_ADMIN,"** Moved up 50 feet.");
}
return 1;
}
}