givecash cmd not working
#1

Код:
dcmd_givecash(playerid, params[])
{
	new pID, value;
    if(sscanf(params, "ui", pID, value)) return SendClientMessage(playerid, COLOR_CMDUSAGE, "USAGE : /givecash [playerid/Part of name] [amount]");
	if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Error : Invalid ID");
    if(value > GetPlayerMoney(playerid)) return SendClientMessage(playerid, -1, "You Dont Have That Much Cash");
    if(pID == playerid) return SendClientMessage(playerid, -1, "That's You, You IDIOT");
    if(value<0) return 0;
    if(GetPlayerScore(playerid) == 0 && value >0) return SendClientMessage(playerid, -1, "You Need Atleast level 1 to givecash");
   	GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
  	GetPlayerName(pID, tName, MAX_PLAYER_NAME);
    format(string, sizeof(string), "You transfered $%i to %s (%i)", value, tName, pID);
    SendClientMessage(playerid, COLOR_YELLOW, string);
    format(string, sizeof(string), "You got $%i by %s (%i)", value, pName, playerid);
    SendClientMessage(pID, COLOR_YELLOW, string);
    GivePlayerMoney(pID, value);
    GivePlayerMoney(playerid, - value);
    return 1;
}
Код:
D:\Server\Server\gamemodes\CbK.pwn(5) : warning 216: nested comment
D:\Server\Server\gamemodes\CbK.pwn(4537) : error 017: undefined symbol "pName"
D:\Server\Server\gamemodes\CbK.pwn(4538) : error 017: undefined symbol "tName"
D:\Server\Server\gamemodes\CbK.pwn(4539) : error 017: undefined symbol "string"
D:\Server\Server\gamemodes\CbK.pwn(4539) : error 017: undefined symbol "string"
D:\Server\Server\gamemodes\CbK.pwn(4539) : error 029: invalid expression, assumed zero
D:\Server\Server\gamemodes\CbK.pwn(4539) : fatal error 107: too many error messages on one line

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


6 Errors.

How to fix this It was working before but I deleted something now its not working I didnt deleted anything serious and I didnt had any error before.
Reply
#2

Код:
dcmd_givecash(playerid, params[])
{
new aName[MAX_PLAYER_NAME], string2[128];
Reply
#3

Add this stock where all the other stocks or publics are:

pawn Код:
stock PlayerName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    for(new i = 0; i < MAX_PLAYER_NAME; i++)
    {
        if(name[i] == '_') name[i] = ' ';
    }
    return name;
}
Then replace your code with this:

pawn Код:
dcmd_givecash(playerid, params[])
{
    new pID, value, string[128];
    if(sscanf(params, "ui", pID, value)) return SendClientMessage(playerid, COLOR_CMDUSAGE, "USAGE : /givecash [playerid/Part of name] [amount]");
    if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Error : Invalid ID");
    if(value > GetPlayerMoney(playerid)) return SendClientMessage(playerid, -1, "You Dont Have That Much Cash");
    if(pID == playerid) return SendClientMessage(playerid, -1, "That's You, You IDIOT");
    if(value<0) return 0;
    if(GetPlayerScore(playerid) == 0 && value >0) return SendClientMessage(playerid, -1, "You Need Atleast level 1 to givecash");
    format(string, sizeof(string), "You transfered $%i to %s (%i)", value, PlayerName(pID), pID);
    SendClientMessage(playerid, COLOR_YELLOW, string);
    format(string, sizeof(string), "You got $%i by %s (%i)", value, PlayerName(playerid), playerid);
    SendClientMessage(pID, COLOR_YELLOW, string);
    GivePlayerMoney(pID, value);
    GivePlayerMoney(playerid, -value);
    return 1;
}
Post me line 5 of your game mode and I'll fix that warning too.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)