[Ajuda] Trocar comando
#1

Como faзo pra deixar esse comando aqui em cmdtext, nгo sei como chama esse aqui que uso, exemplo do que quero trocar:

pawn Код:
if(strcmp(cmd,"/cativeiro",true) == 0)
    {
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,COLOR_123,"USE: /cativeiro [Id] [tempo");
            return true;
        }
        new org = GetPlayerOrg(playerid);
        new para1;
        new time;
        para1 = ReturnUser(tmp);
        tmp = strtok(cmdtext,idx);
        time = strval(tmp);
        if(IsPlayerConnected(para1))
        {
            if(para1 != INVALID_PLAYER_ID)
            {
                if(ProxDetectorS(3.0,playerid,giveplayerid))
                {
                    if(PlayerInfo[para1][pMembro] == 6||PlayerInfo[para1][pLider] == 6)
                    {
                        SendClientMessage(playerid,COLOR_GRAD1,"Vocк nгo pode prender um terrorista no cativeiro.");
                        return true;
                    }
                    GetPlayerName(para1,giveplayer,sizeof(giveplayer));
                    GetPlayerName(playerid,sendername,sizeof(sendername));
                    if ((org == 6) && PlayerToPoint(2.0, playerid,-1104.1871,-1666.2097,76.4672))
                    {
                   ProxDetector(30.0,playerid,string,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                        PlayerInfo[para1][pJailed] = 4;
                        PlayerInfo[para1][pJailTime] = time*60;
                        PlayerInfo[para1][pPnumber] = 0;
                        Telefoneoff[para1] = 1;
                        ResetPlayerWeapons(para1);
                        SetPlayerPos(para1,-1104.1200,-1664.0133,76.4672);
                        SetCameraBehindPlayer(para1);
                    }
                    return true;
                }
                else
                {
                    SendClientMessage(playerid,COLOR_GRAD1," Vocк nгo esta proximo ao cara.");
                }
            }
        }
    }
esse ae й sу um exemplo do que eu quero mudar, pois nгo sei como mudar, quero mudar esse codigo aqui :

pawn Код:
CMD:boombox(playerid, params[])
{
    new string[128];
    if(!GetPVarType(playerid, "BoomboxObject"))
    {
        if(sscanf(params, "s[256]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /boombox [music url]");
        foreach(Player, i)
        {
            if(GetPVarType(i, "BoomboxObject"))
            {
                if(IsPlayerInRangeOfPoint(playerid, 30.0, GetPVarFloat(i, "bposX"), GetPVarFloat(i, "bposY"), GetPVarFloat(i, "bposZ")))
                {
                    SendClientMessage(playerid, COLOR_GREY, " There is another boombox nearby, place yours somewhere else.");
                    return 1;
                }
            }
        }
       
        new Float:x, Float:y, Float:z, Float:a;
        GetPlayerPos(playerid, x, y, z); GetPlayerFacingAngle(playerid, a);
        SetPVarInt(playerid, "BoomboxObject", CreateDynamicObject(2103, x, y, z, 0.0, 0.0, 0.0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid)));
        SetPVarFloat(playerid, "bposX", x); SetPVarFloat(playerid, "bposY", y); SetPVarFloat(playerid, "bposZ", z);
        SetPVarInt(playerid, "bboxareaid", CreateDynamicSphere(x, y, z, 30.0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid)));
        format(string, sizeof(string), " You have placed your boombox at your location.");
        SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
        foreach(Player, i)
        {
            if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "bboxareaid")))
            {
                PlayAudioStreamForPlayer(i, params, GetPVarFloat(playerid, "bposX"), GetPVarFloat(playerid, "bposY"), GetPVarFloat(playerid, "bposZ"), 30.0, 1);
            }
        }
        SetPVarString(playerid, "BoomboxURL", params);
    }
    else
    {
        DestroyDynamicObject(GetPVarInt(playerid, "BoomboxObject"));
        DeletePVar(playerid, "BoomboxObject"); DeletePVar(playerid, "BoomboxURL");
        DeletePVar(playerid, "bposX"); DeletePVar(playerid, "bposY"); DeletePVar(playerid, "bposZ");
        if(GetPVarType(playerid, "bboxareaid"))
        {
            foreach(Player,i)
            {
                if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "bboxareaid")))
                {
                    StopAudioStreamForPlayer(i);
                    SendClientMessage(i, COLOR_GREY, " The boombox creator has removed his boombox.");
                }
            }
            DeletePVar(playerid, "bboxareaid");
        }
        SendClientMessage(playerid, COLOR_LIGHTBLUE, " You have removed your boombox.");
    }
Reply
#2

Vou te falar uma coisa, o zcmd separa os parвmetros do comando, sendo os parвmetros do comando armazenados em params, entгo se o comando sу usa um parвmetro nгo й necessбrio usar sscanf:
pawn Код:
CMD:vida(playerid, params[])
{
    if(!strlen(params)) return SendClientMessage(playerid, -1, "Use: /vida [id]");
    if(!IsPlayerConnected(strval(params))) return SendClientMessage(playerid, -1, "Jogador nгo conectado.");
    SetPlayerHealth(strval(params), 100.0);
    return 1;
}
Estб linha й desnecessбria:
pawn Код:
if(sscanf(params, "s[256]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /boombox [music url]");
Reply
#3

Eu quero mudar o comando para o outro modo, mais nгo sei como..

pawn Код:
if (strcmp(cmd, "/boombox", true) == 0)
    {
        if (IsPlayerConnected(playerid))
        {
            new string[128];
            if (!GetPVarType(playerid, "BoomboxObject"))
            {
                if (sscanf(params, "s[256]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /boombox [music url]");
                foreach(Player, i)
                {
                    if (GetPVarType(i, "BoomboxObject"))
                    {
                        if (IsPlayerInRangeOfPoint(playerid, 30.0, GetPVarFloat(i, "bposX"), GetPVarFloat(i, "bposY"), GetPVarFloat(i, "bposZ")))
                        {
                            SendClientMessage(playerid, COLOR_GREY, " There is another boombox nearby, place yours somewhere else.");
                            return 1;
                        }
                    }
                }

                new Float: x,
                Float: y,
                Float: z,
                Float: a;
                GetPlayerPos(playerid, x, y, z);
                GetPlayerFacingAngle(playerid, a);
                SetPVarInt(playerid, "BoomboxObject", CreateDynamicObject(2103, x, y, z, 0.0, 0.0, 0.0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid)));
                SetPVarFloat(playerid, "bposX", x);
                SetPVarFloat(playerid, "bposY", y);
                SetPVarFloat(playerid, "bposZ", z);
                SetPVarInt(playerid, "bboxareaid", CreateDynamicSphere(x, y, z, 30.0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid)));
                format(string, sizeof(string), " You have placed your boombox at your location.");
                SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                foreach(Player, i)
                {
                    if (IsPlayerInDynamicArea(i, GetPVarInt(playerid, "bboxareaid")))
                    {
                        PlayAudioStreamForPlayer(i, params, GetPVarFloat(playerid, "bposX"), GetPVarFloat(playerid, "bposY"), GetPVarFloat(playerid, "bposZ"), 30.0, 1);
                    }
                }
                SetPVarString(playerid, "BoomboxURL", params);
            }
            else
            {
                DestroyDynamicObject(GetPVarInt(playerid, "BoomboxObject"));
                DeletePVar(playerid, "BoomboxObject");
                DeletePVar(playerid, "BoomboxURL");
                DeletePVar(playerid, "bposX");
                DeletePVar(playerid, "bposY");
                DeletePVar(playerid, "bposZ");
                if (GetPVarType(playerid, "bboxareaid"))
                {
                    foreach(Player, i)
                    {
                        if (IsPlayerInDynamicArea(i, GetPVarInt(playerid, "bboxareaid")))
                        {
                            StopAudioStreamForPlayer(i);
                            SendClientMessage(i, COLOR_GREY, " The boombox creator has removed his boombox.");
                        }
                    }
                    DeletePVar(playerid, "bboxareaid");
                }
                SendClientMessage(playerid, COLOR_LIGHTBLUE, " You have removed your boombox.");
            }
        }
        return 1;
    }
assim?
Reply
#4

Vocк deve estar usando strtok.

Entгo, quando vocк digita um comando, a callback OnPlayerCommandText nгo separa o comando dos parвmetros.

Digamos que tenha o comando /vida e tenha um ъnico parвmetro que seja o id.

E eu digito " /vida 0 ".

Se vocк nгo usar sscanf para separar os comandos dos parвmetros no comeзo da callback:
pawn Код:
new cmd[50 char], params[100 char];
unformat(cmdtext, "s[50]S( )[100]",cmd,params);
Vocк vai ter que usar strtok novamente ou separar dentro do comando:
pawn Код:
if(strcmp(cmd, "/vida", true) == 0)
{
    new id[128] = strtok(cmdtext, idx);
    if(!strlen(id)) return SendClientMessage(playerid, -1, "/vida [id]");
    SetPlayerHealth(strval(id), 100.0);
    return 1;
}
// Separar o comando dos parвmetros:
if(strcmp(cmd, "/vida", true) == 0)
{
    new  cmd[30], id;
    // cmd irб armazenar o comadando. Ex: se eu digitar /vida 0 , o /vida vai ficar armazenado dentro da string cmd.
    // o id irб armazenar o id do jogador escolhido, se eu digitar /vida 10 , o 10 vai ficar armazenado na variбvel.
    if(sscanf(cmdtext, "s[30]u", cmd, id)) return SendClientMessage(playerid, -1, "/vida [id]");
    SetPlayerHealth(id, 100.0);
    return 1;
}
Reply
#5

Comando pronto abaixo, se funcionar avisa aqui no tуpico. Espero ter ajudado!

PHP код:
CMD:cativeiro(playeridparams[])
{
    new 
idplayertempo;
    new 
org GetPlayerOrg(playerid);
    if(
sscanf(params"id"idplayertempo)) return SendClientMessage(playerid,-1,"USE: /cativeiro [Id] [tempo");
    if(!
IsPlayerConnected(idplayer)) return SendClientMessage(playerid, -1"[ ERRO ] Este player nгo estб conectado!");
    if(
ProxDetectorS(3.0,playerid,idplayer))
    {
        if(
PlayerInfo[idplayer][pMembro] == 6||PlayerInfo[idplayer][pLider] == 6) return SendClientMessage(playerid,COLOR_GRAD1,"Vocк nгo pode prender um terrorista no cativeiro.");
        if((
org == 6) && PlayerToPoint(2.0playerid,-1104.1871,-1666.2097,76.4672))
        
ProxDetector(30.0,playerid,string,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        
PlayerInfo[idplayer][pJailed] = 4;
        
PlayerInfo[idplayer][pJailTime] = tempo*60;
        
PlayerInfo[idplayer][pPnumber] = 0;
        
Telefoneoff[idplayer] = 1;
        
ResetPlayerWeapons(idplayer);
        
SetPlayerPos(idplayer,-1104.1200,-1664.0133,76.4672);
        
SetCameraBehindPlayer(idplayer);
        return 
true;
    }
    else
    {
        
SendClientMessage(playerid,COLOR_GRAD1," Vocк nгo esta proximo ao cara.");
    }
    return 
1;

Reply
#6

Quote:
Originally Posted by [BOPE]Seu._.Madruga
Посмотреть сообщение
Comando pronto abaixo, se funcionar avisa aqui no tуpico. Espero ter ajudado!

PHP код:
CMD:cativeiro(playeridparams[])
{
    new 
idplayertempo;
    new 
org GetPlayerOrg(playerid);
    if(
sscanf(params"id"idplayertempo)) return SendClientMessage(playerid,-1,"USE: /cativeiro [Id] [tempo");
    if(!
IsPlayerConnected(idplayer)) return SendClientMessage(playerid, -1"[ ERRO ] Este player nгo estб conectado!");
    if(
ProxDetectorS(3.0,playerid,idplayer))
    {
        if(
PlayerInfo[idplayer][pMembro] == 6||PlayerInfo[idplayer][pLider] == 6) return SendClientMessage(playerid,COLOR_GRAD1,"Vocк nгo pode prender um terrorista no cativeiro.");
        if((
org == 6) && PlayerToPoint(2.0playerid,-1104.1871,-1666.2097,76.4672))
        
ProxDetector(30.0,playerid,string,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        
PlayerInfo[idplayer][pJailed] = 4;
        
PlayerInfo[idplayer][pJailTime] = tempo*60;
        
PlayerInfo[idplayer][pPnumber] = 0;
        
Telefoneoff[idplayer] = 1;
        
ResetPlayerWeapons(idplayer);
        
SetPlayerPos(idplayer,-1104.1200,-1664.0133,76.4672);
        
SetCameraBehindPlayer(idplayer);
        return 
true;
    }
    else
    {
        
SendClientMessage(playerid,COLOR_GRAD1," Vocк nгo esta proximo ao cara.");
    }
    return 
1;

Mas vc nгo entendeu, esse comando ae, й sу uma base de como eu quero trocar, quero trocar esse comando aqui..

pawn Код:
if (strcmp(cmd, "/boombox", true) == 0)
    {
        if (IsPlayerConnected(playerid))
        {
            new string[128];
            if (!GetPVarType(playerid, "BoomboxObject"))
            {
                if (sscanf(params, "s[256]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /boombox [music url]");
                foreach(Player, i)
                {
                    if (GetPVarType(i, "BoomboxObject"))
                    {
                        if (IsPlayerInRangeOfPoint(playerid, 30.0, GetPVarFloat(i, "bposX"), GetPVarFloat(i, "bposY"), GetPVarFloat(i, "bposZ")))
                        {
                            SendClientMessage(playerid, COLOR_GREY, " There is another boombox nearby, place yours somewhere else.");
                            return 1;
                        }
                    }
                }

                new Float: x,
                Float: y,
                Float: z,
                Float: a;
                GetPlayerPos(playerid, x, y, z);
                GetPlayerFacingAngle(playerid, a);
                SetPVarInt(playerid, "BoomboxObject", CreateDynamicObject(2103, x, y, z, 0.0, 0.0, 0.0, .worldid = GetPlayerVirtualWorld(playerid), .interiorid = GetPlayerInterior(playerid)));
                SetPVarFloat(playerid, "bposX", x);
                SetPVarFloat(playerid, "bposY", y);
                SetPVarFloat(playerid, "bposZ", z);
                SetPVarInt(playerid, "bboxareaid", CreateDynamicSphere(x, y, z, 30.0, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid)));
                format(string, sizeof(string), " You have placed your boombox at your location.");
                SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                foreach(Player, i)
                {
                    if (IsPlayerInDynamicArea(i, GetPVarInt(playerid, "bboxareaid")))
                    {
                        PlayAudioStreamForPlayer(i, params, GetPVarFloat(playerid, "bposX"), GetPVarFloat(playerid, "bposY"), GetPVarFloat(playerid, "bposZ"), 30.0, 1);
                    }
                }
                SetPVarString(playerid, "BoomboxURL", params);
            }
            else
            {
                DestroyDynamicObject(GetPVarInt(playerid, "BoomboxObject"));
                DeletePVar(playerid, "BoomboxObject");
                DeletePVar(playerid, "BoomboxURL");
                DeletePVar(playerid, "bposX");
                DeletePVar(playerid, "bposY");
                DeletePVar(playerid, "bposZ");
                if (GetPVarType(playerid, "bboxareaid"))
                {
                    foreach(Player, i)
                    {
                        if (IsPlayerInDynamicArea(i, GetPVarInt(playerid, "bboxareaid")))
                        {
                            StopAudioStreamForPlayer(i);
                            SendClientMessage(i, COLOR_GREY, " The boombox creator has removed his boombox.");
                        }
                    }
                    DeletePVar(playerid, "bboxareaid");
                }
                SendClientMessage(playerid, COLOR_LIGHTBLUE, " You have removed your boombox.");
            }
        }
        return 1;
CMD:boomboxnext(playerid, params[])
{
    if(!Boombox[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You don't have a boombox placed.");
    if(sscanf(params, "s[256]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /boomboxnext [music url]");
    SendClientMessage(playerid, COLOR_GREY, " You have changed the music your boombox is playing.");
    foreach(Player, i)
    {
        if(IsPlayerInDynamicArea(i, GetPVarInt(playerid, "bboxareaid")))
        {
            PlayAudioStreamForPlayer(i, params, GetPVarFloat(playerid, "bposX"), GetPVarFloat(playerid, "bposY"), GetPVarFloat(playerid, "bposZ"), 30.0, 1);
        }
    }
    SetPVarString(playerid, "BoomboxURL", params);
    return 1;
}
para oque vc me mandou, pq ae usa um tipo diferente de comando, nгo lembro o nome..
Reply
#7

Hum, Acho que й assim:

PHP код:
CMD:boombox(playeridparams[])
{
    new 
string[256];
    if(!
IsPlayerConnected(playerid)) return SendClientMessage(playerid, -1"[ ERRO ] Vocк nгo estб conectado no servidor!");
    if(!
GetPVarType(playerid"BoomboxObject"))
    {
        if(
sscanf(params"s[256]"params)) return SendClientMessage(playerid, -1"USAGE: /boombox [music url]");
        foreach(
Playeri)
        {
            if(
GetPVarType(i"BoomboxObject"))
            {
                if(
IsPlayerInRangeOfPoint(playerid30.0GetPVarFloat(i"bposX"), GetPVarFloat(i"bposY"), GetPVarFloat(i"bposZ"))) return SendClientMessage(playeridCOLOR_GREY" There is another boombox nearby, place yours somewhere else.");
                new 
FloatxFloatyFloatzFloata;
                
GetPlayerPos(playeridxyz);
                
GetPlayerFacingAngle(playerida);
                
SetPVarInt(playerid"BoomboxObject"CreateDynamicObject(2103xyz0.00.00.0, .worldid GetPlayerVirtualWorld(playerid), .interiorid GetPlayerInterior(playerid)));
                
SetPVarFloat(playerid"bposX"x);
                
SetPVarFloat(playerid"bposY"y);
                
SetPVarFloat(playerid"bposZ"z);
                
SetPVarInt(playerid"bboxareaid"CreateDynamicSphere(xyz30.0GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid)));
                
format(stringsizeof(string), " You have placed your boombox at your location.");
                
SendClientMessage(playeridCOLOR_LIGHTBLUEstring);
                foreach(
Playeri)
                {
                    if(
IsPlayerInDynamicArea(iGetPVarInt(playerid"bboxareaid"))) PlayAudioStreamForPlayer(iparamsGetPVarFloat(playerid"bposX"), GetPVarFloat(playerid"bposY"), GetPVarFloat(playerid"bposZ"), 30.01);
                }
                
SetPVarString(playerid"BoomboxURL"params);
            }
            else
            {
                
DestroyDynamicObject(GetPVarInt(playerid"BoomboxObject"));
                
DeletePVar(playerid"BoomboxObject");
                
DeletePVar(playerid"BoomboxURL");
                
DeletePVar(playerid"bposX");
                
DeletePVar(playerid"bposY");
                
DeletePVar(playerid"bposZ");
                if(
GetPVarType(playerid"bboxareaid"))
                {
                    foreach(
Playeri)
                    {
                        if(
IsPlayerInDynamicArea(iGetPVarInt(playerid"bboxareaid")))
                        {
                            
StopAudioStreamForPlayer(i);
                            
SendClientMessage(iCOLOR_GREY" The boombox creator has removed his boombox.");
                        }
                    }
                    
DeletePVar(playerid"bboxareaid");
                }
                
SendClientMessage(playeridCOLOR_LIGHTBLUE" You have removed your boombox.");
            }
        }
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)