PDA

View Full Version : [HELP]Commands sscanf & zcmd


TheBluec0de
08/06/2012, 05:37 PM
help, how can I create the command /world id in zcmd with sscanf, limit is 99 example.. and in the command set the variable Worlds[playerid] = 1;

Niko_boy
08/06/2012, 05:44 PM
CMD:world(playerid , params[])
{
new world;
if(sscanf(params,"i",world)) return SendClientMessage(playerid,-1,"/word <worldid>");
if(0=< world < 99)
{
SetPlayerVirtualWorld(playerid,world);
// set variable to player worldid ?
Worlds[playerid] = world;
SendClientMessage(playerid,-1,"Success!");
}else return SendClientMessage(playerid,-1,"Valid id 0-99");
return 1;
}

Kindred
08/06/2012, 05:45 PM
CMD:world(playerid, params[])
{
new id;
if(sscanf(params, "i", id)) return SendClientMessage(playerid, -1, "Usage: /world [id]");
if(id > 99 || id < 0) return SendClientMessage(playerid, -1, "Limit: 0-99);
Worlds[playerid] = id;
return 1;
}


Not quite sure what you wanted. Didn't know whether to make Worlds = id, or make it one. I just made it so that it sets the players Worlds variable to the id the put in.

EDIT: Looks like I was too late.

TheBluec0de
08/06/2012, 05:57 PM
CMD:world(playerid , params[])
{
new world;
if(sscanf(params,"i",world)) return SendClientMessage(playerid,-1,"/word <worldid>");
if(0=< world < 99)
{
SetPlayerVirtualWorld(playerid,world);
// set variable to player worldid ?
Worlds[playerid] = world;
SendClientMessage(playerid,-1,"Success!");
}else return SendClientMessage(playerid,-1,"Valid id 0-99");
return 1;
}

dosent work

warning 219: local variable "i" shadows a variable at a preceding level
warning 211: possibly unintended assignment
error 022: must be lvalue (non-constant)
error 029: invalid expression, assumed zero
warning 215: expression has no effect
error 001: expected token: ";", but found ")"
fatal error 107: too many error messages on one line

TheBluec0de
08/06/2012, 06:34 PM
bump

Jefff
08/06/2012, 06:40 PM
CMD:world(playerid,params[])
{
new world;
if(!('0' <= params[0] <= '9')) SendClientMessage(playerid,-1,"/word <worldid>");
else if(!(0 <= (world = strval(params)) <= 99)) SendClientMessage(playerid,-1,"Valid id 0-99");
else{
SetPlayerVirtualWorld(playerid,world);
Worlds[playerid] = world;
SendClientMessage(playerid,-1,"Success!");
}
return 1;
}

TheBluec0de
08/06/2012, 10:31 PM
CMD:world(playerid,params[])
{
new world;
if(!('0' <= params[0] <= '9')) SendClientMessage(playerid,-1,"/word <worldid>");
else if(!(0 <= (world = strval(params)) <= 99)) SendClientMessage(playerid,-1,"Valid id 0-99");
else{
SetPlayerVirtualWorld(playerid,world);
Worlds[playerid] = world;
SendClientMessage(playerid,-1,"Success!");
}
return 1;
}

if(!('0' <= params[0] <= '9')) SendClientMessage(playerid,-1,"/word <worldid>"); --->>>> 9 ?

Dubya
08/06/2012, 11:44 PM
CMD:world(playerid,params[])
{
new world;
if(!('0' <= params[0] <= '9')) SendClientMessage(playerid,-1,"/World [World ID]");
else if(!(0 <= (world = strval(params)) <= 99)) SendClientMessage(playerid,-1,"Valid id 0-99");
else
{
SetPlayerVirtualWorld(playerid,world);
Worlds[playerid] = world;
SendClientMessage(playerid,-1,"Success!");
}
return 1;
}

.FuneraL.
08/06/2012, 11:50 PM
CMD:world(playerid, params[])
{
new World;
if(sscanf(params, "d", World)) return SendClientMessage(playerid, -1, "Usage: /world [ID World]");
if(World < 1 || World > 99) return SendClientMessage(playerid, -1, "[ERROR]: Worlds 1 - 99");
SetPlayerVirtualWorld(playerid, World);
return 1;
}

Try.

TheBluec0de
09/06/2012, 12:11 AM
CMD:world(playerid, params[])
{
new World;
if(sscanf(params, "d", World)) return SendClientMessage(playerid, -1, "Usage: /world [ID World]");
if(World < 1 || World > 99) return SendClientMessage(playerid, -1, "[ERROR]: Worlds 1 - 99");
SetPlayerVirtualWorld(playerid, World);
return 1;
}

Try.

Thanks