PDA

View Full Version : Only between 0-36?


Blackazur
22/05/2013, 06:31 PM
Hellow, how to make that you can only change the map between 0-36?

CMD:nextmap(playerid,params[])
{
if(pInfo[playerid][pLogged] == 1)
{
if(pInfo[playerid][pAdminLevel] >= 3)
{
new map,stringmap[256];
if(sscanf(params,"i", map)) return SendClientMessage(playerid,-1,""chat" /nextmap [mapid]");

format(stringmap,sizeof(stringmap),""chat""COL_LIGHTBLUE" Next Map ID has been setted to %i!",map);
SendClientMessageToAll(-1,stringmap);
mapid = map;
}
}
return 1;
}

CreativityLacker
22/05/2013, 06:34 PM
CMD:nextmap(playerid,params[])
{
if(pInfo[playerid][pLogged] == 1)
{
if(pInfo[playerid][pAdminLevel] >= 3)
{
new map,stringmap[256];
if(sscanf(params,"d", map)) return SendClientMessage(playerid,-1,""chat" /nextmap [mapid]");
if(map < 0 || map > 36) return SendClientMessage(playerid, -1, "Map ID must be between 0 and 36");
format(stringmap,sizeof(stringmap),""chat""COL_LIGHTBLUE" Next Map ID has been setted to %i!",map);
SendClientMessageToAll(-1,stringmap);
mapid = map;
}
}
return 1;
}

CreativityLacker
22/05/2013, 06:51 PM
clamp (http://wiki.sa-mp.com/wiki/Clamp)

Interesting function, thanks for sharing :O

But, it wouldn't be very useful in this case

Eg. someone uses

/nextmap 37
While really he wanted to use
/nextmap 3
It'll return
/nextmap 36

It'd be better to actually tell the user to insert a proper value rather than round it off to the maximum value, it might cause problems, but that's a pretty amazing function (clamp) :D