Help with a cmd
#1

i want a /portloc cmd and put cords and tele port to were the cords were
here is one of the cmds i use
pawn Код:
if(strcmp(cmd, "/goto", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_ERROR, "Syntax: /goto (playername/id)");
                return 1;
            }
            new Float:plocx,Float:plocy,Float:plocz;
            new plo;
            plo = ReturnUser(tmp);
            if(IsPlayerNPC(plo)) return 1;
            if(IsPlayerConnected(plo))
            {
                if(plo != INVALID_PLAYER_ID)
                {
                    if(PInfo[playerid][AdminLevel] >= 1)
                    {
                        new interior = GetPlayerInterior(plo);
                        new vw = GetPlayerVirtualWorld(plo);
                        SetPlayerVirtualWorld(playerid,vw);
                        SetPlayerInterior(playerid,interior);
                        GetPlayerPos(plo, plocx, plocy, plocz);
                        if(GetPlayerState(playerid) == 2)
                        {
                            new tmpcar = GetPlayerVehicleID(playerid);
                            SetVehiclePos(tmpcar, plocx, plocy+4, plocz);
                        }
                        else
                        {
                            SetPlayerPos(playerid,plocx,plocy+2, plocz);
                        }
                        new sendmsg[128];
                        format(sendmsg,sizeof(sendmsg),"Administrator {FF9900}%s(%d) {FFFFFF}has teleported to your location.", PlayerName(playerid), playerid);
                        SendClientMessage(plo, COLOR_WHITE, sendmsg);
                        format(sendmsg,sizeof(sendmsg),"You have teleported to {FF9900}%s's(%d) {FFFFFF}location.", PlayerName(plo), plo);
                        SendClientMessage(playerid, COLOR_WHITE, sendmsg);
                        AdminLog(playerid, "/teleto", "Teleported To", PlayerName(plo));
                        return 1;
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator !");
                    }
                }
            }
            else
            {
                format(string, sizeof(string), "Could not find player (%d)", plo);
                SendClientMessage(playerid, COLOR_ERROR, string);
            }
        }
        return 1;
    }
if you dont understand me here is a cmd of what i mean but its in another type
pawn Код:
COMMAND:portloc(playerid, params[])
{
    // Setup local variables
    new Float:x, Float:y, Float:z, PortMsg[128];

    // Send the command to all admins so they can see it
    SendAdminText(playerid, "/portloc", params);

    // Check if the player has logged in
    if (APlayerData[playerid][LoggedIn] == true)
    {
        // Check if the player's admin-level is at least 1
        if (APlayerData[playerid][PlayerLevel] >= 1)
        {
            // Check if the player has a wanted level of less than 3
            if (GetPlayerWantedLevel(playerid) < 3)
            {
                // Check if the player is not jailed
                if (APlayerData[playerid][PlayerJailed] == 0)
                {
                    if (sscanf(params, "fff", x, y, z)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/portloc <x> <y> <z>\"");
                    else
                    {
                        // Port the player to the given location
                        SetPlayerPos(playerid, x, y, z);
                        // Let the player know about it
                        format(PortMsg, 128, "You have been ported to location: %4.2f, %4.2f, %4.2f", x, y, z);
                        SendClientMessage(playerid, 0x00FF00FF, PortMsg);
                    }
                }
                else
                    SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot use /portloc when you're in jail");
            }
            else
                SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}You cannot use /portloc when you're wanted");
        }
        else
            return 0;
    }
    else
        return 0;

    // Let the server know that this was a valid command
    return 1;
}
thanks
Reply
#2

This should work.


pawn Код:
if(strcmp(cmd, "/portloc", true) == 0)
    {
        new Float:plocx,Float:plocy,Float:plocz;
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, plocx, plocy, plocz);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_ERROR, "Syntax: /portloc(X,Y,Z");
                return 1;
            }
            if(PInfo[playerid][AdminLevel] >= 1)
            {
                  if(GetPlayerState(playerid) == 2)
                  {
                        new tmpcar = GetPlayerVehicleID(playerid);
                        SetVehiclePos(tmpcar, plocx, plocy+4, plocz);
                  }
                  else
                  {
                        SetPlayerPos(playerid,plocx,plocy+2, plocz);
                  }
                  return 1;
                  {
                  else
                  {
                        SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator !");
                    }
                }
            }
        }
        return 1;
    }
Reply
#3

Thanks alot of Helping but i got warning a error
pawn Код:
C:\Users\Daoud\Desktop\Pilots heaven\gamemodes\PH.pwn(18546) : warning 213: tag mismatch
C:\Users\Daoud\Desktop\Pilots heaven\gamemodes\PH.pwn(18546) : warning 202: number of arguments does not match definition
C:\Users\Daoud\Desktop\Pilots heaven\gamemodes\PH.pwn(18546) : warning 202: number of arguments does not match definition
C:\Users\Daoud\Desktop\Pilots heaven\gamemodes\PH.pwn(18564) : warning 225: unreachable code
C:\Users\Daoud\Desktop\Pilots heaven\gamemodes\PH.pwn(18565) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
Reply
#4

What line gives you trouble? paste us the line.
Reply
#5

Line 18565 is
pawn Код:
else
Reply
#6

Try this
pawn Код:
if(strcmp(cmd, "/portloc", true) == 0)
    {
        new Float:plocx,Float:plocy,Float:plocz;
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, plocx, plocy, plocz);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_ERROR, "Syntax: /portloc(X,Y,Z");
                return 1;
            }
            if(PInfo[playerid][AdminLevel] >= 1)
            {
                  if(GetPlayerState(playerid) == 2)
                  {
                        new tmpcar = GetPlayerVehicleID(playerid);
                        SetVehiclePos(tmpcar, plocx, plocy+4, plocz);
                  }
                  else
                  {
                        SetPlayerPos(playerid,plocx,plocy+2, plocz);
                  }
                  return 1;
            }
            else
            {
                        SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator !");
            }


         }
           
       
      return 1;
    }
Reply
#7

WORKED thanks +1
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)