PLease help with /givecash
#1

Hi! when i insert /givecash cmd in my GM then i hvae 4 errors in one line!

there is my /givecash
Код:
	if(strcmp(cmd, "/givecash", true) == 0) {

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

		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp)) {
			SendClientMessage(playerid, COLOR_WHITE, "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 (id: %d), $%d.", giveplayer,giveplayerid, moneys);
				SendClientMessage(playerid, COLOR_YELLOW, string);
				format(string, sizeof(string), "You have recieved $%d from %s (id: %d).", moneys, sendername, playerid);
				SendClientMessage(giveplayerid, COLOR_YELLOW, string);
				printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
			}
			else {
				SendClientMessage(playerid, COLOR_YELLOW, "Invalid transaction amount.");
			}
		}
		else {
				format(string, sizeof(string), "%d is not an active player.", giveplayerid);
				SendClientMessage(playerid, COLOR_YELLOW, string);

			}
		return 1;
 		}
and bottom of the script:
Код:
stock strtok(const string[], &index)
{
	new length = strlen(string);
	while ((index < length) && (string[index] <= ' '))
	{
		index++;
	}

	new offset = index;
	new result[20];
	while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
	{
		result[index - offset] = string[index];
		index++;
	}
	result[index - offset] = EOS;
	return result;
}
Whats wrong?
Reply
#2

And that line would be?...
Reply
#3

error line is:
Код:
		(1510)tmp = strtok(cmdtext, idx);
		(1511)if(!strlen(tmp)) {
			(1512)SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
Reply
#4

It would help if you posted the errors too
Reply
#5

error:
Код:
C:\Documents and Settings\Martins\Desktop\Jauna mape32\SA-MP serveris\gamemodes\Fizzy.pwn(1512) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Martins\Desktop\Jauna mape32\SA-MP serveris\gamemodes\Fizzy.pwn(1512) : warning 215: expression has no effect
C:\Documents and Settings\Martins\Desktop\Jauna mape32\SA-MP serveris\gamemodes\Fizzy.pwn(1512) : error 001: expected token: ";", but found ")"
C:\Documents and Settings\Martins\Desktop\Jauna mape32\SA-MP serveris\gamemodes\Fizzy.pwn(1512) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Martins\Desktop\Jauna mape32\SA-MP serveris\gamemodes\Fizzy.pwn(1512) : fatal error 107: too many error messages on one line

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


4 Errors.
Reply
#6

This is /givecash from LVDM and I assume you made no major changes. Replace it with this which compiles fine (this is directly from LVDM by Jax):
pawn Код:
if(strcmp(cmd, "/givecash", true) == 0) {
      new tmp[256];
        tmp = strtok(cmdtext, idx);

        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
            return 1;
        }
        giveplayerid = strval(tmp);
       
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_WHITE, "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, COLOR_YELLOW, string);
                format(string, sizeof(string), "You have recieved $%d from %s(player: %d).", moneys, sendername, playerid);
                SendClientMessage(giveplayerid, COLOR_YELLOW, string);
                printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
            }
            else {
                SendClientMessage(playerid, COLOR_YELLOW, "Invalid transaction amount.");
            }
        }
        else {
                format(string, sizeof(string), "%d is not an active player.", giveplayerid);
                SendClientMessage(playerid, COLOR_YELLOW, string);
            }
        return 1;
    }
Reply
#7

Dont work then i have 4 errors and 2 warnings
Reply
#8

you sure that oyu place it in OnPlayerCommandText and defined everything?
Reply
#9

Yes all i iam defined but is 4 errors. I copy givecash from LVDM
Reply
#10

pawn Код:
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)