[Ajuda] comando /setworld
#1

PS: Nгo me julguem,ainda estou aprendendo.

O que hб de errado com meu comando?

Quote:

if(strcmp(cmd,"/setworld",true) == 0)
{
new world;
tmp=strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid,-1,"Use /setworld [WORLD]");
world=strval(tmp);
if(world <= 1 || world >= 255)
SetPlayerVirtualWorld(playerid,world);
return 1;
}

Vi um tutorial de strtok e usei um comando como exemplo,mas ele nгo muda a world.
Reply
#2

Quote:
Originally Posted by safchdion
Посмотреть сообщение
PS: Nгo me julguem,ainda estou aprendendo.

O que hб de errado com meu comando?



Vi um tutorial de strtok e usei um comando como exemplo,mas ele nгo muda a world.
Aparentemente seu cуdigo esta correto !

@edit
Vocк quer setar a world do jogador que usar o comando certo ?

@off
Aconselharia a usar sscanf !
Reply
#3

Quote:
Originally Posted by Glederson_dom
Посмотреть сообщение
Aparentemente seu cуdigo esta correto !

@edit
Vocк quer setar a world do jogador que usar o comando certo ?

@off
Aconselharia a usar sscanf !
Sim...Vou usar apenas pra uma finalidade especifica entгo й pra quem usar.
Depois verei um tutorial de sscanf,mais queria arrumar esse pra aprender =)
Mesmo assim obrigado pela resposta,vou tentar arrumar aqui.
Reply
#4

Jб consegui arrumar
Quote:

if(world <= 1 || world >= 255)

Troquei pra if(world >=0)
Reply
#5

Pode usar isso como Filterscript que vai funcionar

Код:
#include <a_samp>

public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[100], idx;
    cmd = strtok(cmdtext, idx);
    
    if (strcmp("/setworld", cmd, true) == 0)
    {
    if (IsPlayerAdmin(playerid))
    {
    new tmp1[128], tmp2[128];
    tmp1 = strtok(cmdtext, idx);
    tmp2 = strtok(cmdtext, idx);
    if (!strlen(tmp1) || !strlen(tmp2)) return SendClientMessage(playerid, -1, "{FFFFFF}Use: /setworld [player] [world]");
    if (IsPlayerConnected(strval(tmp1))) return SendClientMessage(playerid, -1, "{FFFFFF}Player nгo conectado.");
    SetPlayerVirtualWorld(strval(tmp1),strval(tmp2));
 }
    return 1;
 }
	return 0;
}


strtok(const string[], &index)
{
   new length = strlen(string);
   while ((index < length) && (string[index] <= ' '))
   {
      index++;
   }
   new offset = index;
   new result[20];
   while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
   {
      result[index - offset] = string[index];
      index++;
   }
   result[index - offset] = EOS;
   return result;
}
Reply
#6

Quote:
Originally Posted by RedMF
Посмотреть сообщение
Pode usar isso como Filterscript que vai funcionar

Код:
#include <a_samp>

public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[100], idx;
    cmd = strtok(cmdtext, idx);
    
    if (strcmp("/setworld", cmd, true) == 0)
    {
    if (IsPlayerAdmin(playerid))
    {
    new tmp1[128], tmp2[128];
    tmp1 = strtok(cmdtext, idx);
    tmp2 = strtok(cmdtext, idx);
    if (!strlen(tmp1) || !strlen(tmp2)) return SendClientMessage(playerid, -1, "{FFFFFF}Use: /setworld [player] [world]");
    if (IsPlayerConnected(strval(tmp1))) return SendClientMessage(playerid, -1, "{FFFFFF}Player nгo conectado.");
    SetPlayerVirtualWorld(strval(tmp1),strval(tmp2));
 }
    return 1;
 }
	return 0;
}


strtok(const string[], &index)
{
   new length = strlen(string);
   while ((index < length) && (string[index] <= ' '))
   {
      index++;
   }
   new offset = index;
   new result[20];
   while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
   {
      result[index - offset] = string[index];
      index++;
   }
   result[index - offset] = EOS;
   return result;
}
Nгo man eu jб consegui arrumar,mais obrigado mesmo assim.
=)
Reply
#7

ok
Reply
#8

E ai safchdion, tudo bem?
Sу queria deixar um code aqui, rs...
Код:
                new
                      cmd[256], idx;
                cmd = strtok(cmdtext, idx);
                if(strcmp(cmd, "/SetVirtualWorld", true) == 0)
		{
		    cmd = strtok(cmdtext, idx);
		    if(!strlen(cmd))
		    {
		        SendClientMessage(playerid, Vermelho, "[>]"BRANCO" Use /Set VirtualWorld [Player] [Virtual World]");
		        return 1;
		    }
		    new
		        id = strval(cmd);
			if(!IsPlayerConnected(id))
			{
			    SendClientMessage(playerid, Vermelho, "[>]"BRANCO" Player offline");
			    return 1;
			}
			cmd = strtok(cmdtext, idx);
		    if(!strlen(cmd))
		    {
		        SendClientMessage(playerid, Vermelho, "[>]"BRANCO" Use /Set VirtualWorld [Player] [Virtual World]");
		        return 1;
		    }
		    new
		        vw = strval(cmd);
			if(vw < 0)
			{
			    SendClientMessage(playerid, Vermelho, "[>]"BRANCO" O Virtual World deve ser maior ou igual a 0");
			    return 1;
			}
			SetPlayerVirtualWorld(id, vw);
			format(String, sizeof(String), " O administrador %s setou seu virtual world para %d", pName(playerid), vw);
			SendClientMessage(id, Amarelo, String);
			format(String, sizeof(String), "Vocк setou o virtual world do player %s para %d", pName(id), vw);
			SendClientMessage(playerid, Amarelo, String);
Abraзos
Reply
#9

Quote:
Originally Posted by pPawn
Посмотреть сообщение
E ai safchdion, tudo bem?
Sу queria deixar um code aqui, rs...
Код:
                new
                      cmd[256], idx;
                cmd = strtok(cmdtext, idx);
                if(strcmp(cmd, "/SetVirtualWorld", true) == 0)
		{
		    cmd = strtok(cmdtext, idx);
		    if(!strlen(cmd))
		    {
		        SendClientMessage(playerid, Vermelho, "[>]"BRANCO" Use /Set VirtualWorld [Player] [Virtual World]");
		        return 1;
		    }
		    new
		        id = strval(cmd);
			if(!IsPlayerConnected(id))
			{
			    SendClientMessage(playerid, Vermelho, "[>]"BRANCO" Player offline");
			    return 1;
			}
			cmd = strtok(cmdtext, idx);
		    if(!strlen(cmd))
		    {
		        SendClientMessage(playerid, Vermelho, "[>]"BRANCO" Use /Set VirtualWorld [Player] [Virtual World]");
		        return 1;
		    }
		    new
		        vw = strval(cmd);
			if(vw < 0)
			{
			    SendClientMessage(playerid, Vermelho, "[>]"BRANCO" O Virtual World deve ser maior ou igual a 0");
			    return 1;
			}
			SetPlayerVirtualWorld(id, vw);
			format(String, sizeof(String), " O administrador %s setou seu virtual world para %d", pName(playerid), vw);
			SendClientMessage(id, Amarelo, String);
			format(String, sizeof(String), "Vocк setou o virtual world do player %s para %d", pName(id), vw);
			SendClientMessage(playerid, Amarelo, String);
Abraзos
Legal man,talvez alguйm veja esse fуrum e esteja precisando
Ou atй mesmo eu mais tarde pra incrementar o meu estude o seu,obrigado ^^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)