/givecash problem easy?
#1

Код:
if(strcmp(cmd, "/givecash", true) == 0) {
	new tmp[256];
	tmp = strtok(cmdtext, idx);
	if(!strlen(tmp)) {
	SendClientMessage(playerid, VALGE, "USAGE: /givecash [playerid] [amount]");
	return 1;
	}
	giveplayerid = strval(tmp);
	tmp = strtok(cmdtext, idx);
	if(!strlen(tmp)) {
	SendClientMessage(playerid, VALGE, "USAGE: /givecash [playerid] [amount]");
	return 1;
	}
 	moneys = strval(tmp);
	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), "* Sa saatsid %s %d krooni", giveplayer,moneys);
	SendClientMessage(playerid, LILLA, string);
	format(string, sizeof(string), "* Sa said %d krooni  Saatja: %s", moneys, sendername);
	SendClientMessage(giveplayerid, LILLA, string);
	printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
	}
	else {
	SendClientMessage(playerid, PUNANE, "Vale Summa");
	}
	}
	else {
	format(string, sizeof(string), "%d pole serveris!", giveplayerid);
	SendClientMessage(playerid, PUNANE, string);
	}
	return 1;
	}
Код:
C:\DOCUME~1\Andrus\Desktop\ARMBYA~1\GAMEMO~1\rp.pwn(649) : warning 219: local variable "tmp" shadows a variable at a preceding level
C:\DOCUME~1\Andrus\Desktop\ARMBYA~1\GAMEMO~1\rp.pwn(655) : error 017: undefined symbol "giveplayerid"
C:\DOCUME~1\Andrus\Desktop\ARMBYA~1\GAMEMO~1\rp.pwn(661) : error 017: undefined symbol "moneys"
C:\DOCUME~1\Andrus\Desktop\ARMBYA~1\GAMEMO~1\rp.pwn(662) : error 017: undefined symbol "giveplayerid"
C:\DOCUME~1\Andrus\Desktop\ARMBYA~1\GAMEMO~1\rp.pwn(663) : error 017: undefined symbol "giveplayerid"
C:\DOCUME~1\Andrus\Desktop\ARMBYA~1\GAMEMO~1\rp.pwn(663) : error 017: undefined symbol "giveplayer"
C:\DOCUME~1\Andrus\Desktop\ARMBYA~1\GAMEMO~1\rp.pwn(663) : error 029: invalid expression, assumed zero
C:\DOCUME~1\Andrus\Desktop\ARMBYA~1\GAMEMO~1\rp.pwn(663) : fatal error 107: too many error messages on one line

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


7 Errors.
Reply
#2

Here's an example using DCMD and SSCANF (only ones I use)

pawn Код:
dcmd_give(playerid, params[])
{
new str[15], id, val
if(!sscanf(params, "sud", str, id, val))
{
if(!strcmp(str,"money",true))
{
GivePlayerMoney(id, val);
return 1;
}
else return SendClientMessage(playerid, color, "Usage: /give <money> <Playername/ID> <amount>");
}
That would be

Код:
/give money Joe_ 5000
Lol, sorry you updated your post before I made this.
Reply
#3

pawn Код:
if(strcmp(cmd, "/givecash", true) == 0) {
    new tmp[256], giveplayerid, moneys, giveplayer[MAX_PLAYER_NAME];
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)) {
    SendClientMessage(playerid, VALGE, "USAGE: /givecash [playerid] [amount]");
    return 1;
    }
    giveplayerid = strval(tmp);
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)) {
    SendClientMessage(playerid, VALGE, "USAGE: /givecash [playerid] [amount]");
    return 1;
    }
    moneys = strval(tmp);
    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), "* Sa saatsid %s %d krooni", giveplayer,moneys);
    SendClientMessage(playerid, LILLA, string);
    format(string, sizeof(string), "* Sa said %d krooni  Saatja: %s", moneys, sendername);
    SendClientMessage(giveplayerid, LILLA, string);
    printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
    }
    else {
    SendClientMessage(playerid, PUNANE, "Vale Summa");
    }
    }
    else {
    format(string, sizeof(string), "%d pole serveris!", giveplayerid);
    SendClientMessage(playerid, PUNANE, string);
    }
    return 1;
    }
Reply
#4

now i got this

Код:
C:\DOCUME~1\Andrus\Desktop\ARMBYA~1\GAMEMO~1\rp.pwn(648) : warning 219: local variable "tmp" shadows a variable at a preceding level
C:\DOCUME~1\Andrus\Desktop\ARMBYA~1\GAMEMO~1\rp.pwn(664) : error 017: undefined symbol "playermoney"
C:\DOCUME~1\Andrus\Desktop\ARMBYA~1\GAMEMO~1\rp.pwn(665) : error 017: undefined symbol "playermoney"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply
#5

I have to say this; FIX IT!

Scratch that, please TRY AND FIX IT before you ask HOW to fix it.

pawn Код:
if(strcmp(cmd, "/givecash", true) == 0) {
new giveplayerid, moneys, giveplayer[MAX_PLAYER_NAME], playermoney
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, VALGE, "USAGE: /givecash [playerid] [amount]");
return 1;
}
giveplayerid = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, VALGE, "USAGE: /givecash [playerid] [amount]");
return 1;
}
    moneys = strval(tmp);
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), "* Sa saatsid %s %d krooni", giveplayer,moneys);
SendClientMessage(playerid, LILLA, string);
format(string, sizeof(string), "* Sa said %d krooni  Saatja: %s", moneys, sendername);
SendClientMessage(giveplayerid, LILLA, string);
printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
}
else {
SendClientMessage(playerid, PUNANE, "Vale Summa");
}
}
else {
format(string, sizeof(string), "%d pole serveris!", giveplayerid);
SendClientMessage(playerid, PUNANE, string);
}
return 1;
}
Reply
#6

i got fixed now 1 warning

warning 219: local variable "tmp" shadows a variable at a preceding level

Got Fixed thanks for help
Reply
#7

Compile? I didn't get that.
Reply
#8

Everything is alright
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)