what's wrong ?
#1

What's wrong with this command ?

Код:
CMD:givegun(playerid, params[])
{
        new string[128], target, gun;
        if(APlayerData[playerid][PlayerLevel] >= 5) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!");
        if(sscanf(params, "ud", target, gun)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /givegun <playerid> <gun>");
        if(gun < 1 || gun > 47) return SendClientMessage(playerid, COLOR_GREY, "Don't go below 1 or above 47.");
        if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_GREY, "User is not connected!");
        if(gun != 21)
        {
             GivePlayerWeapon(target, gun, 50000); //Your version would be GivePlayerValidWeapon, this also may be causing issues.
             format(string, sizeof(string), "Admin %s has given you a weapon.", PlayerName(playerid));
             SendClientMessage(target, COLOR_YELLOW, string);
             format(string, sizeof(string), "You have given %s a weapon.", PlayerName(target));
             SendClientMessage(playerid, COLOR_YELLOW, string);
        }
        return 1;
}
Errors :

Код:
(13824) : error 012: invalid function call, not a valid address
(13824) : warning 215: expression has no effect
(13824) : error 001: expected token: ";", but found ")"
(13824) : error 029: invalid expression, assumed zero
(13824) : fatal error 107: too many error messages on one line
Reply
#2

where is the error line?
Reply
#3

Paste us the error line!
Reply
#4

Here it is

Код:
format(string, sizeof(string), "Admin %s has given you a weapon.", PlayerName(playerid));
Reply
#5

i allways use like that:
pawn Код:
new Str[128];
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(Str, sizeof(Str), "Name: %s", pName);
SendClientMessage(playerid, 0xFFFF00FF, Str);
Reply
#6

Show your PlayerName function.
Reply
#7

I got it defined under 'enum'

Код:
// Setup all the fields required for the player data (Speedometer TextDraw, current job, ...)
enum TPlayerData
{
	PlayerName[24], // Holds the name of the player
Like that. I don't know if that's the correct way, but if I add

Код:
stock PlayerName(playerid) 
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
It will say that I already have 'GetPlayerName' and 'PlayerName' defined.
Reply
#8

pawn Код:
stock GetName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
Then change PlayerName(playerid) and PlayerName(targetid) to GetName(playerid) and GetName(targetid).
You're using two things of the same name, and it's confusing the compiler as to which one you want to use.
Reply
#9

Got it all sorted, thanks for the help guys, appreciate it !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)