Kind of teleport command
#1

Hello.

I have been reading about strtok, strcmp etc etc..
But i can't seem to find a solution on how to make this.

What i want to do, is a command similar to this /level [0-10].
An example is, if you type /level 0 you'll get to an underground parking, but if you type /level 2, you'll get to the second level of a building.
And if you just type /level, it sais Usage: /level [0-10].

The command will set player position in different x, y, z and virtual worlds but i know how to do that.

The question is, am i supposed to make a command for all levels, like:
if(strcmp(cmd, "/level 0", true) == 0
SetPlayerPos etc etc
if(strcmp(cmd, "/level 5", true) == 0
SetPlayerPos etc etc..

- Or is it possible to make a more advanced /level command where it finds out what level the person is typing?

Any help is appreciated.


If there is an "advanced command", then please give an example of how it could be for just 2 levels. then i can modify it for several levels.
Thanks alot.

Reply
#2

look into dcmd or zcmd and sscanf, it makes coding a lot easier and it's a lot faster.
Reply
#3

pawn Код:
dcmd_level(playerid,params[])
{
    if(!params[0])
    {
        SendClientMessage(playerid,0xC06716FF,"USAGE: /level [0 - 10]");
        return 1;
    }
    new level;
    level = strval(params);
    switch(level)
    {
      case 0:
      {
        // /level 0 - code here
      }
      case 1:
      {
        // /level 1 - code here
      }
      case 2:
      {
        // /level 2 - code here
      }
      //etc.
     
        default:
        {
          //In case they type any other number
          SendClientMessage(playerid,0xC06716FF,"USAGE: /level [0 - 10]");
          return 1;
        }
    }
}
That should be a working dcmd version.
Reply
#4

Oh christ!

Thanks champ!


I just made a command for each /level... works as a charm, but took 700 lines :P


I will choose this next time im gonna make anything similar..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)