SA-MP Forums Archive
Why Doesnt This Code Work? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Why Doesnt This Code Work? (/showthread.php?tid=71768)



Why Doesnt This Code Work? - DorkAZoid - 03.04.2009

Hello All
i have a simple /givecash command but it doesnt compile:
Код:
#include <a_samp>
#include <core>
#include <float>

#pragma tabsize 0

#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define PocketMoney 5000 // Amount player recieves on spawn.
#define INACTIVE_PLAYER_ID 255
#define GIVECASH_DELAY 5000 // Time in ms between /givecash commands.

#define NUMVALUES 4

forward MoneyGrubScoreUpdate();
forward Givecashdelaytimer(playerid);
forward SetPlayerRandomSpawn(playerid);
forward SetupPlayerForClassSelection(playerid);
forward GameModeExitFunc();
forward SendPlayerFormattedText(playerid, const str[], define);
forward public SendAllFormattedText(playerid, const str[], define);

new CashScoreOld;
new cmd;
new strtok;
Thats what i have at the beggining and the /givemoney code:
Код:
	if(strcmp(cmd, "/givecash", true) == 0) {
	  new tmp[256];
		tmp = strtok(cmdtext, idx);

		if(!strlen(tmp)) {
			SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /givecash [playerid] [amount]");
			return 1;
		}
		giveplayerid = strval(tmp);

		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp)) {
			SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /givecash [playerid] [amount]");
			return 1;
		}
 		moneys = strval(tmp);

		//printf("givecash_command: %d %d",giveplayerid,moneys);


		if (IsPlayerConnected(giveplayerid)) {
			GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
			GetPlayerName(playerid, sendername, sizeof(sendername));
			playermoney = GetPlayerMoney(playerid);
			if (moneys > 0 && playermoney >= moneys) {
				GivePlayerMoney(playerid, (0 - moneys));
				GivePlayerMoney(giveplayerid, moneys);
				format(string, sizeof(string), "You have sent %s(player: %d), $%d.", giveplayer,giveplayerid, moneys);
				SendClientMessage(playerid, 0xFFFF00AA, string);
				format(string, sizeof(string), "You have recieved $%d from %s(player: %d).", moneys, sendername, playerid);
				SendClientMessage(giveplayerid, 0xFFFF00AA, string);
				printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
			}
			else {
				SendClientMessage(playerid, 0xFFFF00AA, "Invalid transaction amount.");
			}
		}
		else {
				format(string, sizeof(string), "%d is not an active player.", giveplayerid);
				SendClientMessage(playerid, 0xFFFF00AA, string);
			}
		return 1;
	}

	// PROCESS OTHER COMMANDS
	
		return 0;
	}
And the compiler error:
Код:
D:\Gta sa\GTA San Andreas\gamemodes\sfdm.pwn(337) : error 035: argument type mismatch (argument 1)
D:\Gta sa\GTA San Andreas\gamemodes\sfdm.pwn(339) : error 012: invalid function call, not a valid address
D:\Gta sa\GTA San Andreas\gamemodes\sfdm.pwn(339) : warning 215: expression has no effect
D:\Gta sa\GTA San Andreas\gamemodes\sfdm.pwn(339) : error 017: undefined symbol "idx"
D:\Gta sa\GTA San Andreas\gamemodes\sfdm.pwn(339) : error 029: invalid expression, assumed zero
D:\Gta sa\GTA San Andreas\gamemodes\sfdm.pwn(339) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.
Please i need help.

~Ali~


Re: Why Doesnt This Code Work? - MenaceX^ - 03.04.2009

It's taken from lvdm, isn't it?


Re: Why Doesnt This Code Work? - Jefff - 03.04.2009

Quote:
Originally Posted by ..::DorkAZoid::..
new cmd;
new strtok;
Learn more PAWN


Re: Why Doesnt This Code Work? - MenaceX^ - 03.04.2009

Quote:
Originally Posted by Jefff
Quote:
Originally Posted by ..::DorkAZoid::..
new cmd;
new strtok;
Learn more PAWN
They need helpers to.