Simple command issue.
#5

firstly, if you are writing a gamemode yourself, you should consider using a fast command processor like zcmd
https://sampforum.blast.hk/showthread.php?tid=91354
if you decide to use zcmd, I suggest you also use sscanf(2)
https://sampforum.blast.hk/showthread.php?tid=120356
It will be harder at first, but a lot easier as you learn more.

If you are editing a gamemode, I suggest you consider converting it to zcmd and sscanf. If you don't want to convert it, then look closely at the OnPlayerCommandText() callback.

In your post above you are not using strcmp correctly, specifically the length parameter. Read this.
https://sampwiki.blast.hk/wiki/Strcmp

The first thing you do is define the variables you will be using in your commands.
Then you use strtok to separate the command from the rest of the parameters.
Then you use strcmp to process the command.
inside the command script, you keep using strtok to remove parameters from cmdtext one word at a time, using idx as a reference.

pawn Код:
public OnPlayerCommandText(playerid,cmdtext[])
{
     new cmd[32],idx,tmp[32],string[164];
     cmd = strtok(cmdtext, idx);
     if(!strcmp(cmd,"/hold",true))
     {
         tmp = strtok(cmdtext, idx);
         if(!strlen(tmp))
         {
              SendClientMessage(playerid,0xAFAFAFAA,"/hold [hold name] ( available names: briefcase, bottle, cigar, surfboard...)");
         }
         //rest of command here
once you have mastered this you can move on to the SetPlayerHoldingObject command, read this.
https://sampwiki.blast.hk/wiki/SetPlayerHoldingObject


good luck!
Reply


Messages In This Thread
Simple command issue. - by Snyper1 - 08.10.2010, 00:25
Re: Simple command issue. - by TheHoodRat - 08.10.2010, 00:32
Re: Simple command issue. - by Snyper1 - 08.10.2010, 01:24
Re: Simple command issue. - by Snyper1 - 08.10.2010, 01:32
Re: Simple command issue. - by Rachael - 08.10.2010, 01:49
Re: Simple command issue. - by Snyper1 - 08.10.2010, 02:23

Forum Jump:


Users browsing this thread: 3 Guest(s)