[SOLVED] Command Not Working!
#1

Pawno will not compile this. if I comment it away it will compile. What is wrong?

Код:
	if(strcmp("/pickup",cmdtext, true) == 0)
	{
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
		{
			SendClientMessage(playerid, ORANGE, "USAGE: /pickup");
			SendClientMessage(playerid, ORANGE, "FUNCTION: Will Send A Message To All Asking Them To Pick You Up!");
			return 1;
	 	}
			GetPlayerName(playerid, sendername, sizeof(sendername));
			format(string, sizeof(string), "%s Has Requested To Be Picked Up", sendername);
			SendClientMessageToAll(ADMIN_RED, string);
			format(string, sizeof(string), "Your Request To Be Picked Up Has Been Sent. Thank You.");
			SendClientMessage(playerid, GREEN, string);
		}
		return 1;
  }
Reply
#2

Try this:
pawn Код:
if(strcmp("/pickup",cmdtext, true) == 0)
    {
        //Removed the "Usage:" thingy you did, There is no use to it... in this Command
        new string[128];//Added the Symbol define for the String
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "%s Has Requested To Be Picked Up", sendername);
        SendClientMessageToAll(ADMIN_RED, string);
        SencClientMessage(playerid, GREEN, "Your Request To Be Picked Up Has Been Sent. Thank You.");//Changed the "Format" you made into a simple Client Message
    }
    return 1;
    }
Should Work, Read my Comments in the code about what I did...
Hope it will help you....
Reply
#3

you have one unneeded } which fucks everything up
pawn Код:
if(strcmp("/pickup",cmdtext, true) == 0)
    {
        new sendername;
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "%s Has Requested To Be Picked Up", sendername);
        SendClientMessageToAll(ADMIN_RED, string);
        SendClientMessage(playerid, GREEN, "Your Request To Be Picked Up Has Been Sent. Thank You.");
    return 1;
    }
This will do it

Also, castle's code defines "string" - doing that can make errors if you have "string" already defined, so better don't do that
Reply
#4

I have treid them both but they give errors.

Castle:
Код:
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Freeroam.pwn(807) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Freeroam.pwn(810) : error 017: undefined symbol "sendername"
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Freeroam.pwn(810) : error 017: undefined symbol "sendername"
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Freeroam.pwn(810) : error 029: invalid expression, assumed zero
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Freeroam.pwn(810) : fatal error 107: too many error messages on one line
Zoopaman:
Код:
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Freeroam.pwn(807) : warning 217: loose indentation
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Freeroam.pwn(809) : error 017: undefined symbol "tmp"
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Freeroam.pwn(809) : error 017: undefined symbol "strtok"
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Freeroam.pwn(810) : error 017: undefined symbol "tmp"
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Freeroam.pwn(816) : error 017: undefined symbol "sendername"
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Freeroam.pwn(816) : error 017: undefined symbol "sendername"
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Freeroam.pwn(816) : error 029: invalid expression, assumed zero
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\gamemodes\Freeroam.pwn(816) : fatal error 107: too many error messages on one line
Reply
#5

I have it working now! Using:

Код:
if(strcmp("/pickup",cmdtext, true) == 0)
	{
	  new string[128];
	  new sendername[MAX_PLAYER_NAME];
		GetPlayerName(playerid, sendername, sizeof(sendername));
		format(string, sizeof(string), "%s Has Requested To Be Picked Up", sendername);
		SendClientMessageToAll(COLOR_ADMIN_RED, string);
		SendClientMessage(playerid, COLOR_GREEN, "Your Request To Be Picked Up Has Been Sent. Thank You.");
		return 1;
	}
Thanks for the help!
Reply
#6

Was about to say that strtok was pointless >.>
Reply
#7

Quote:
Originally Posted by Zoopaman
you have one unneeded } which fucks everything up
pawn Код:
if(strcmp("/pickup",cmdtext, true) == 0)
    {
        new sendername;
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "%s Has Requested To Be Picked Up", sendername);
        SendClientMessageToAll(ADMIN_RED, string);
        SendClientMessage(playerid, GREEN, "Your Request To Be Picked Up Has Been Sent. Thank You.");
    return 1;
    }
This will do it

Also, castle's code defines "string" - doing that can make errors if you have "string" already defined, so better don't do that
Sorry You are right on that string is mght be defined..
when I define stuff like format i create something like:
pawn Код:
new rMSG[128];
but here I didn't knew which script he uses so i made it simple...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)