Move cmd help
#1

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;
        }
Reply
#2

use sscanf2 by ******
Reply
#3

I wouldnt know how to script it. If you can, can you make a zcmd ?
Reply
#4

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!
Reply
#5

Too many errors. Can you change to zcmd for me
Reply
#6

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.
Reply
#7

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;
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)