/z /y /x commands
#1

how can i make a command that when i type /z 10 it adds 10 to the /z coordinate and when i do /z -10 it subtracts
and the same for /x and /y

please help
Reply
#2

pawn Код:
dcmd_x(playerid, p)
{
  new
      Float:x,
      Float:y,
      Float:z;
  if(!strlen(params))
    return SendClientMessage(playerid, 0xFFFF00FF, "USAGE: \"/x [positive or negative float]\"");
  GetPlayerPos(playerid, x, y, z);
  SetPlayerPos(playerid, x+p, y, z);
  return true;
}
Reply
#3


so this would work for /z right?
Код:
dcmd_x(playerid, p)
{
  new
      Float:x,
      Float:y,
      Float:z;
  if(!strlen(params))
    return SendClientMessage(playerid, 0xFFFF00FF, "USAGE: \"/z [positive or negative float]\"");
  GetPlayerPos(playerid, x, y, z);
  SetPlayerPos(playerid, x, y, z+p);
  return true;
}



I get this error


C:\PROGRA~1\ROCKST~1\GTASAN~1\GTAU-S~1.WIN\GAMEMO~1\UBERST~1.PWN(949) : warning 203: symbol is never used: "dcmd_x"
Reply
#4

That's because I've used DCMD

look up https://sampwiki.blast.hk/wiki/Fast_Commands

or just use this code:

pawn Код:
if(!strcmp(cmdtext, "/x", true))
{
  new
      Float:x,
      Float:y,
      Float:z;
  if(cmdtext[2] != 32 || cmdtext[3] == EOS)
    return SendClientMessage(playerid, 0xFFFF00FF, "USAGE: \"/x [positive or negative float]\"");
  GetPlayerPos(playerid, x, y, z);
  SetPlayerPos(playerid, x+floatstr(cmdtext[3]), y, z);
  return true;
}
Reply
#5

Here all three commands are in dcmd:

put under OnPlayerCommandText
Код:
{
     dcmd(x, 1, cmdtext);
     dcmd(y, 1, cmdtext);
     dcmd(z, 1, cmdtext);
}

dcmd_x(playerid, params[])
{
     new
          Float:x,
          Float:y,
          Float:z;
     if(!strlen(params))
       return SendClientMessage(playerid, 0xFFFF00FF, "USAGE: \"/x [positive or negative float]\"");
     GetPlayerPos(playerid, x, y, z);
     SetPlayerPos(playerid, x+params, y, z);
     return true;
}

dcmd_y(playerid, params[])
{
     new
          Float:x,
          Float:y,
          Float:z;
     if(!strlen(params))
       return SendClientMessage(playerid, 0xFFFF00FF, "USAGE: \"/y [positive or negative float]\"");
     GetPlayerPos(playerid, x, y, z);
     SetPlayerPos(playerid, x, y+params, z);
     return true;
}

dcmd_z(playerid, params[])
{
     new
          Float:x,
          Float:y,
          Float:z;
     if(!strlen(params))
       return SendClientMessage(playerid, 0xFFFF00FF, "USAGE: \"/z [positive or negative float]\"");
     GetPlayerPos(playerid, x, y, z);
     SetPlayerPos(playerid, x, y, z+params);
     return true;
}
Should work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)