CMD does not set world. -
Яσскѕтая - 22.07.2010
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;
}
Re: CMD does not set world. -
DJDhan - 22.07.2010
Код:
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;
}
Re: CMD does not set world. -
Яσскѕтая - 22.07.2010
Код:
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.
Re: CMD does not set world. -
DJDhan - 22.07.2010
Okay, just change the array sizes from 128 to 256.
Re: CMD does not set world. -
Last_Stand_Guardian - 22.07.2010
The error says that the tmp size is to small.
Try:
Re: CMD does not set world. -
Яσскѕтая - 22.07.2010
It's still not changing the world.
Re: CMD does not set world. -
DJDhan - 22.07.2010
How do you know it's not changing the world? Do you have other players which type this command but don't disappear?
Re: CMD does not set world. -
Яσскѕтая - 22.07.2010
No I have a /myworld which displays the world, and I can see the spawn cars.
Re: CMD does not set world. - [L3th4l] - 22.07.2010
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
Re: CMD does not set world. -
Яσскѕтая - 22.07.2010
I like sticking with regular commands. I actually understand them.