CMD does not set world.
#1

I tried to make this so it set's the player world, fixing one I had before but now it does not do anything.
Code:
pawn Код:
if(!strcmp(cmdtext, "/world", true))
{
    if(!cmdtext[6])return SendClientMessage(playerid, COLOR_RED, "USAGE: /world [word 0 - 500000]");
    if(cmdtext[7] > 500000) return SendClientMessage(playerid,COLOR_RED,"Invalid world ID.");
    if(cmdtext[7] < 0) return SendClientMessage(playerid,COLOR_RED,"Invalid world ID.");
    new string[256];
    new tmp[256];
    tmp = strtok(cmdtext[7],idx);
    format(string, sizeof(string), "You have set your world to %s",tmp);
    SetPlayerVirtualWorld(playerid, cmdtext[7]);
    SendClientMessage(playerid, COLOR_GREEN, string);
    return 1;
}
Reply
#2

Код:
if(!strcmp(cmdtext, "/world", true))
{
	new string[256], tmp[256],wid,Index;    
	
	tmp = strtok(cmdtext,Index);    
	if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /world worldid [0 - 500000]");

	wid = strval(tmp);	    
	if(wid < 0 || wid > 500000) return SendClientMessage(playerid,COLOR_RED,"Invalid world ID  [0 - 500000]");  
      
	SetPlayerVirtualWorld(playerid, wid);    
	
	format(string, 128, "You have set your world to %d",wid);
	SendClientMessage(playerid, COLOR_GREEN, string);
	
	return 1;
}
Reply
#3

Код:
C:\Servers\SA-MP\gamemodes\MS.pwn(2043) : error 047: array sizes do not match, or destination array is too small
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#4

Okay, just change the array sizes from 128 to 256.
Reply
#5

The error says that the tmp size is to small.
Try:
pawn Код:
new tmp[256];
Reply
#6

It's still not changing the world.
Reply
#7

How do you know it's not changing the world? Do you have other players which type this command but don't disappear?
Reply
#8

No I have a /myworld which displays the world, and I can see the spawn cars.
Reply
#9

i HIGHLY recommend using zcmd, first because its faster. 2nd because its easier to code: btw, also add sscanf there:

pawn Код:
CMD:world(playerid,params[])
{
    new ID;
    if(sscanf(params,"d",ID)) return SendClientMessage(playerid, COLOR_RED,"USAGE: /Setworld < worldid >");
    SetPlayerVirtualWorld(playerid,ID);
    return 1;
}
as you see, less lines and it does what you want. if you use strcmp in your gamemode, probably you can use zcmd commands in a filterscript. Because OnPlayerCommandText and zcmd aren't compatible. So yeah, easy as it is
Reply
#10

I like sticking with regular commands. I actually understand them.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)