2 attributes cmd
#1

How to make 2 attributes cmd? (No LARP edit)
cmd will like /cmdtext 1attr 2attr
Reply
#2

Use sscanf.
Reply
#3

https://sampwiki.blast.hk/wiki/Fast_Commands
Reply
#4

hmm can you give me sample? i dont sleep last night so it's hard to think
Reply
#5

I prefer strtok.

Eg: The sethealth command in dcmd

Код:
dcmd_sethealth(playerid,params[])
{
  if(!IsPlayerAdmin(playerid) return SendClientMessage(playerid,oxffffffaa, "You are not authorised to use this command");

  new tmp[128],tmp2[128],health,targetid,Index;
  tmp=strtok(params,Index);
  tmp2=strtok(params,Index);
  if(!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid, oxffffffaa, " Usage: /sethealth playerid health");
  if(strval(tmp2)>100) return SendClientMessage(playerid, oxffffffaa, " Invalid health amount.");

  targetid=strval(tmp);
  health=strval(tmp2);

  SetPlayerHealth(targetid,health);
  
  return 1;
}
Above is a very basic sethealth command using dcmd and strtok.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)