Kind of teleport command - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Kind of teleport command (
/showthread.php?tid=142751)
Kind of teleport command -
Faith - 19.04.2010
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.
Re: Kind of teleport command -
cessil - 20.04.2010
look into dcmd or zcmd and sscanf, it makes coding a lot easier and it's a lot faster.
Re: Kind of teleport command -
Backwardsman97 - 20.04.2010
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.
Re: Kind of teleport command -
Faith - 20.04.2010
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..