10.05.2009, 10:16
ive been trying to do this using YSF's plugin but i suck with strings and stuff can anyone help me?
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], tmp[256], idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/mygravity", true) ==0)
{
tmp = strtok(cmdtext, idx);
new Float:Gravity = floatstr(tmp);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "USAGE: /gravity [number]");
if(Gravity < 0.001 || Gravity > 0.900) return SendClientMessage(playerid, COLOR_RED, "Gravity has to be within 0.001 and 0.900");
new string[128];
format(string, sizeof(string), "You have changed your own gravity to: %0.3f", Gravity);
SendClientMessage(playerid, COLOR_YELLOW, string);
SetPlayerGravity(playerid, Gravity);
return 1;
}
//other commands
return 0;
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(mygravity, 9, cmdtext);
//other stuff
return 0;
}
dcmd_mygravity(playerid, params[])
{
new Float:Gravity = floatstr(params);
if(sscanf(params, "f", Gravity)) return SendClientMessage(playerid, COLOR_RED, "SYNTAX ERROR: Usage: /setgravity <gravity>");
if(Gravity < 0.001 || Gravity > 0.900) return SendClientMessage(playerid, COLOR_RED, "Gravity has to be within 0.001 and 0.900");
new string[128];
format(string, sizeof(string), "You have changed your own gravity to: %0.3f", Gravity);
SendClientMessage(playerid, COLOR_YELLOW, string);
SetPlayerGravity(playerid, Gravity);
return 1;
}
Originally Posted by |∞|-Рцппσĵσ-|∞|
dcmd with sscanf:
[/pawn] |