SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 23/03/2009, 08:48 PM   #1
Scoots
Big Clucker
 
Join Date: Jul 2008
Posts: 71
Reputation: 0
Default PLease help with /givecash

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

there is my /givecash
Code:
	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:
Code:
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?
Scoots is offline  
Old 23/03/2009, 08:49 PM   #2
Dujma
Huge Clucker
 
Join Date: Jul 2008
Posts: 415
Reputation: 0
Default Re: PLease help with /givecash

And that line would be?...
Dujma is offline  
Old 23/03/2009, 08:51 PM   #3
Scoots
Big Clucker
 
Join Date: Jul 2008
Posts: 71
Reputation: 0
Default Re: PLease help with /givecash

error line is:
Code:
		(1510)tmp = strtok(cmdtext, idx);
		(1511)if(!strlen(tmp)) {
			(1512)SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
Scoots is offline  
Old 23/03/2009, 08:52 PM   #4
ICECOLDKILLAK8
High-roller
 
Join Date: Aug 2008
Posts: 1,154
Reputation: 5
Default Re: PLease help with /givecash

It would help if you posted the errors too
__________________
IVMP
ICECOLDKILLAK8 is offline  
Old 23/03/2009, 08:55 PM   #5
Scoots
Big Clucker
 
Join Date: Jul 2008
Posts: 71
Reputation: 0
Default Re: PLease help with /givecash

error:
Code:
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 (c) 1997-2006, ITB CompuPhase


4 Errors.
Scoots is offline  
Old 23/03/2009, 09:01 PM   #6
Pyrokid
Huge Clucker
 
Join Date: May 2006
Posts: 482
Reputation: 0
Default Re: PLease help with /givecash

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 Code:
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;
    }
Pyrokid is offline  
Old 23/03/2009, 09:07 PM   #7
Scoots
Big Clucker
 
Join Date: Jul 2008
Posts: 71
Reputation: 0
Default Re: PLease help with /givecash

Dont work then i have 4 errors and 2 warnings
Scoots is offline  
Old 23/03/2009, 09:08 PM   #8
Rks25
High-roller
 
Join Date: Jun 2007
Posts: 1,071
Reputation: 4
Default Re: PLease help with /givecash

you sure that oyu place it in OnPlayerCommandText and defined everything?
Rks25 is offline  
Old 23/03/2009, 09:13 PM   #9
Scoots
Big Clucker
 
Join Date: Jul 2008
Posts: 71
Reputation: 0
Default Re: PLease help with /givecash

Yes all i iam defined but is 4 errors. I copy givecash from LVDM
Scoots is offline  
Old 23/03/2009, 09:17 PM   #10
MenaceX^
High-roller
 
Join Date: Aug 2008
Posts: 3,262
Reputation: 13
Default Re: PLease help with /givecash

pawn Code:
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecash [playerid] [amount]");
MenaceX^ is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
/givecash 02manchestera Help Archive 3 14/03/2010 02:51 PM
Givecash bug Puzi Help Archive 5 07/03/2010 01:23 AM
givecash Lajko1 Help Archive 6 09/10/2009 10:06 PM
givecash CJ101 Help Archive 1 19/02/2009 02:05 PM
/givecash amrour Help Archive 5 15/02/2009 03:55 PM


All times are GMT. The time now is 12:12 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.