SA-MP Forums Archive
[Ajuda] comando /setworld - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] comando /setworld (/showthread.php?tid=613138)



comando /setworld - safchdion - 25.07.2016

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.


Respuesta: comando /setworld - SammyJ - 25.07.2016

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 !


Re: Respuesta: comando /setworld - safchdion - 25.07.2016

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.


Re: comando /setworld - safchdion - 25.07.2016

Jб consegui arrumar
Quote:

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

Troquei pra if(world >=0)


Re: comando /setworld - RedMF - 25.07.2016

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;
}



Re: comando /setworld - safchdion - 25.07.2016

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.
=)


Re: comando /setworld - RedMF - 25.07.2016

ok


Re: comando /setworld - pPawn - 25.07.2016

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


Re: comando /setworld - safchdion - 25.07.2016

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 ^^