PDA

View Full Version : Something wrong with this?


NekoChan
12/08/2013, 04:28 AM
if(iTargetID GetPlayerCash(playerid) <=1)
{
SendClientMessageEx(playerid, COLOR_GRAD1, "You can't take money from him/her.");
return 1;
}


Is something wrong with it? can you tell what is it? I'm still new on scripting...

verlaj
12/08/2013, 04:32 AM
it seems you didn't defined iTargetID, try using sscan2 to do it so

there are some small mistakes

if(GetPlayerMoney(iTargetID) <=1)
{
SendClientMessage(playerid, COLOR_GRAD1, "You can't take money from him/her.");
return 1;
}

NekoChan
12/08/2013, 04:35 AM
C:\DOCUME~1\winxp\Desktop\GGRPSC~1\GAMEMO~1\GGRP.p wn(47981) : error 001: expected token: ")", but found "-identifier-"
C:\DOCUME~1\winxp\Desktop\GGRPSC~1\GAMEMO~1\GGRP.p wn(47981) : warning 215: expression has no effect
C:\DOCUME~1\winxp\Desktop\GGRPSC~1\GAMEMO~1\GGRP.p wn(47981) : error 001: expected token: ";", but found ")"
C:\DOCUME~1\winxp\Desktop\GGRPSC~1\GAMEMO~1\GGRP.p wn(47981) : error 029: invalid expression, assumed zero
C:\DOCUME~1\winxp\Desktop\GGRPSC~1\GAMEMO~1\GGRP.p wn(47981) : 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.

These are the errors

verlaj
12/08/2013, 04:43 AM
lets get started with simpler code

under

onplayerspawn
{
if(GetPlayerMoney(playerid <=1)
{
SendClientMessage(playerid, COLOR_GRAD1, "You dont have more than 1$.");
}
return 1;
}

now lets try this out with sscanf2 and zcmd (includes)


CMD:pay(playerid,params[]) //nor mal example
{
new
ID,
amount,
name[MAX_PLAYERS],
string7[200],
name2[MAX_PLAYERS],
string8[200];
if(sscanf(params, "ui", ID,amount)) return SendClientMessage(playerid, -1, "Usage: /pay [playerid] [amount]");
if(amount > GetPlayerMoney(playerid)) return SendClientMessage(playerid, -1, "[ERROR]: You do not have enough money to pay that player!");
if(amount <= 0) return SendClientMessage(playerid, -1, "[ERROR]: You cannot pay less than $1!");
if(playerid == ID) return SendClientMessage(playerid, -1, "[ERROR]: You can't pay yourselve!");
GetPlayerName(ID, name2, sizeof(name2));
format(string8, sizeof(string8),"You have paid %s $%i", name2, amount);
SendClientMessage(playerid, COLOR_RED, string8);
GetPlayerName(playerid, name, sizeof(name));
format(string7, sizeof(string7), "%s(%d) Has paid you: $%i", name, playerid, amount);
SendClientMessage(ID, COLOR_RED, string7);
GivePlayerMoney(ID, amount);
GivePlayerMoney(playerid, -amount);
return 1;
}