Help making a /go cmd
#1

Hello, I want to make a /go command as a teleport command which will teleport you to destinations, like..
If you type "/go place1" it would tp you to "place1", and if you type "/go place2" it would teleport you to "place2" I hope anyone can help me out here, because I've tried to make it but I couldn't make it work :/
If there's already a post like this, then I'm sorry but I couldn't find it, and I didn't know what I should try searching for.
Reply
#2

Which Command Processor? (ZCMD,strcmp,YCMD,dcmd)
Reply
#3

ZCMD
Reply
#4

pawn Код:
CMD:go(playerid, params[])
{
     new string[50];
     if(sscanf(params, "s[50]", string)) return SendClientMessage(playerid, COLOUR, "error message");
     if(strcmp(string, "place1", true) == 0)
     {
             //code
       }
      else if(strcmp(string, "superduperjump", true) == 0)
      {
             //code
       }
       //continue this
   return 1;
}
untested and not neet made in box
Reply
#5

Okay, thanks IceCube, but I don't want to copy&paste, and it seems a bit too complicated for me and my scripting experience, so I guess I'll have to wait trying to use this as I don't really understand a lot from it, so I think I'll either see if someone knows an easier way, or till my scripting will be better ^^
But thanks a lot tho!
Reply
#6

basically, it checks what you typed...if what you typed is place1, you could do something. you could add in that if statement SetPlayerPos(playerid, x,y,z); and change x,y,z to the co-ords you want them to be at
Reply
#7

Thats the only Way I know how to do i but let me explain

pawn Код:
CMD:go(playerid, params[])
{
     new string[50];
     if(sscanf(params, "s[50]", string)) return SendClientMessage(playerid, COLOUR, "error message");
     if(strcmp(string, "place1", true) == 0)
     {
             //code
       }
      else if(strcmp(string, "superduperjump", true) == 0)
      {
             //code
       }
       //continue this
   return 1;
}
Thats the code I gave you.

Let me explain the functions.

strcmp - String Compare - TO check if one peice of text matchs the other. Pleacing this into a if statement allows you to check if it reaches a certain value the values can be:

-1 if string 1 comes before string 2
1 if string 1 comes after string 2
0 if the strings are the same for lengh.

Okay so now wwe knoe that we know that 0 must be the one we want the result to be.
pawn Код:
else if(strcmp(string, "superduperjump", true) == 0)
In this example string is what the player types so thats one string. the second is what you want the string to be.

now the true statement in this means do you want the cases to match. 1 being no 0 being yes please 1 = true 2= false.

THe layout (credits to wiki) is:

(const string1[], const string2[], bool:ignorecase, length)
string1 The first string to compare.
string2 The second string to compare.
ignorecase (optional) When set to true, the case doesn't matter - HeLLo is the same as Hello. When false, they're not the same.
length (optional) When this length is set, the first x chars will be compared - doing "Hello" and "Hell No" with a length of 4 will say it's the same string.

sscanf - Downloadable and saves a lot of hard work - For an explaination on this check your PM's for my skype.

Hope I helped also the caode you need to place inside the bracets would be:

pawn Код:
SetPlayerPos(playerid, x, y, z) // the xyz can be found by going into samp debug saving the plyer pos then getting it from the file,
SetPlayerInterior(playerid, interior); interior can be found here... [url]http://weedarr.wikidot.com/interior[/url]
SetPlayerVirtualWorld(playerid, world); // this is anynumber that you want it to be the same number as another world means that the players in that world number can see each other.
If you need any further help skype me
Reply
#8

Thanks a lot, you sure did explain that very well, I'm pretty sure I can understand it now!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)