[Need help] Make /badge cmd for Police Department
#1

I tried creating command to help SAPD Faction onduty without lockers.

This is my Script:

Код:
CMD:badge(playerid, params[])
{
    new
        string[128],
        string2[64];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
	if(IsACop(playerid))
	{
if(!PlayerInfo[playerid][pFacDuty])
	                {
	                    PlayerInfo[playerid][pFacDuty] = 1;
	                    SetPlayerColor(playerid, TRANSPARENT_BLUE);
	                    format(string, sizeof(string), "* %s grabs their badge, gun and mp5 from the locker.", RPN(playerid));
						SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
						GiveZaiatWeapon(playerid, 29, 500);
						GiveZaiatWeapon(playerid, 24, 200);
						SetPlayerArmour(playerid, 100);
						return 1;
	                }
	                else
	                {
      					PlayerInfo[playerid][pFacDuty] = 0;
	                    SetPlayerColor(playerid, TRANSPARENT_WHITE);
	                    SetPlayerArmour(playerid, 0);
	                    format(string, sizeof(string), "* %s places their badge in the locker.", RPN(playerid));
						SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
						return 1;
	                }
	                }
}
But it's not work. 3 Error line:

Quote:

E:\***(1255 : warning 204: symbol is assigned a value that is never used: "string2"
E:***(12558 -- 12583) : warning 209: function "cmd_badge" should return a value
E:\***(23723) : warning 203: symbol is never used: "badge"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


3 Warnings.

Can you help me fix this error?
Reply
#2

pawn Код:
CMD:badge(playerid, params[])
{
    new
        string[128],
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(IsACop(playerid))
    {
if(!PlayerInfo[playerid][pFacDuty])
                    {
                        PlayerInfo[playerid][pFacDuty] = 1;
                        SetPlayerColor(playerid, TRANSPARENT_BLUE);
                        format(string, sizeof(string), "* %s grabs their badge, gun and mp5 from the locker.", RPN(playerid));
                        SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                        GiveZaiatWeapon(playerid, 29, 500);
                        GiveZaiatWeapon(playerid, 24, 200);
                        SetPlayerArmour(playerid, 100);
                        return 1;
                    }
                    else
                    {
                        PlayerInfo[playerid][pFacDuty] = 0;
                        SetPlayerColor(playerid, TRANSPARENT_WHITE);
                        SetPlayerArmour(playerid, 0);
                        format(string, sizeof(string), "* %s places their badge in the locker.", RPN(playerid));
                        SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                       
                    }
                    }
return 1;
}
Somewhere in your script there is a "new badge" wich you're not using, remove it or keep it, it wont cause any damage anyway.
Reply
#3

Quote:
Originally Posted by Strier
Посмотреть сообщение
pawn Код:
CMD:badge(playerid, params[])
{
    new
        string[128],
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(IsACop(playerid))
    {
if(!PlayerInfo[playerid][pFacDuty])
                    {
                        PlayerInfo[playerid][pFacDuty] = 1;
                        SetPlayerColor(playerid, TRANSPARENT_BLUE);
                        format(string, sizeof(string), "* %s grabs their badge, gun and mp5 from the locker.", RPN(playerid));
                        SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                        GiveZaiatWeapon(playerid, 29, 500);
                        GiveZaiatWeapon(playerid, 24, 200);
                        SetPlayerArmour(playerid, 100);
                        return 1;
                    }
                    else
                    {
                        PlayerInfo[playerid][pFacDuty] = 0;
                        SetPlayerColor(playerid, TRANSPARENT_WHITE);
                        SetPlayerArmour(playerid, 0);
                        format(string, sizeof(string), "* %s places their badge in the locker.", RPN(playerid));
                        SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                       
                    }
                    }
return 1;
}
Somewhere in your script there is a "new badge" wich you're not using, remove it or keep it, it wont cause any damage anyway.
Thank you but ...

Quote:

E:\zGamingRoleplay\gamemodes\ZRP.pwn(12556) : error 001: expected token: "-identifier-", but found "if"
E:\zGamingRoleplay\gamemodes\ZRP.pwn(12580) : warning 217: loose indentation

Reply
#4

Someone plz help me...
Reply
#5

pawn Код:
CMD:badge(playerid, params[])
{
    new string[128];
    if(pInfo[playerid][Member] == 9)
    {
        Group_SetPlayer(Police, playerid, true);
        SetPlayerColor(playerid, TRANSPARENT_BLUE);
        format(string, sizeof(string), "* %s grabs their badge, gun and mp5 from the locker.", RPN(playerid));
        SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        GivePlayerWeapon(playerid, 29, 500);
        GivePlayerWeapon(playerid, 24, 200);
        SetPlayerArmour(playerid, 100);
        return 1;
    }
    else
    {
        Group_SetPlayer(gCivil, playerid, false);
        SetPlayerColor(playerid, TRANSPARENT_WHITE);
        SetPlayerArmour(playerid, 0);
        format(string, sizeof(string), "* %s places their badge in the locker.", RPN(playerid));
        SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    }
    return 1;
}
Didn't test it.. but it could work!
Reply
#6

Quote:
Originally Posted by TrueForYourSelf
Посмотреть сообщение
pawn Код:
CMD:badge(playerid, params[])
{
    new string[128];
    if(pInfo[playerid][Member] == 9)
    {
        Group_SetPlayer(Police, playerid, true);
        SetPlayerColor(playerid, TRANSPARENT_BLUE);
        format(string, sizeof(string), "* %s grabs their badge, gun and mp5 from the locker.", RPN(playerid));
        SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        GivePlayerWeapon(playerid, 29, 500);
        GivePlayerWeapon(playerid, 24, 200);
        SetPlayerArmour(playerid, 100);
        return 1;
    }
    else
    {
        Group_SetPlayer(gCivil, playerid, false);
        SetPlayerColor(playerid, TRANSPARENT_WHITE);
        SetPlayerArmour(playerid, 0);
        format(string, sizeof(string), "* %s places their badge in the locker.", RPN(playerid));
        SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    }
    return 1;
}
Didn't test it.. but it could work!
That script don't work ...
Error:
Quote:

E:\zGamingRoleplay\gamemodes\ZRP.pwn(12555) : error 028: invalid subscript (not an array or too many subscripts): "pInfo"
E:\zGamingRoleplay\gamemodes\ZRP.pwn(12555) : warning 215: expression has no effect
E:\zGamingRoleplay\gamemodes\ZRP.pwn(12555) : error 001: expected token: ";", but found "]"
E:\zGamingRoleplay\gamemodes\ZRP.pwn(12555) : error 029: invalid expression, assumed zero
E:\zGamingRoleplay\gamemodes\ZRP.pwn(12555) : fatal error 107: too many error messages on one line

Reply
#7

pawn Код:
CMD:badge(playerid, params[])
{
    new string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(IsACop(playerid))
    {
        if(!PlayerInfo[playerid][pFacDuty])
        {
            PlayerInfo[playerid][pFacDuty] = 1;
            SetPlayerColor(playerid, TRANSPARENT_BLUE);
            format(string, sizeof(string), "* %s grabs their badge, gun and mp5 from the locker.", RPN(playerid));
            SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
            GiveZaiatWeapon(playerid, 29, 500);
            GiveZaiatWeapon(playerid, 24, 200);
            SetPlayerArmour(playerid, 100);
        }
        else
        {
            PlayerInfo[playerid][pFacDuty] = 0;
            SetPlayerColor(playerid, TRANSPARENT_WHITE);
            SetPlayerArmour(playerid, 0);
            format(string, sizeof(string), "* %s places their badge in the locker.", RPN(playerid));
            SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        }
    }
    return 1;
}
Reply
#8

Why does everyone keep that other "return 1;" there? It doesn't hurt to remove that one as well.
Reply
#9

Quote:
Originally Posted by Scrillex
Посмотреть сообщение
pawn Код:
CMD:badge(playerid, params[])
{
    new string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(IsACop(playerid))
    {
        if(!PlayerInfo[playerid][pFacDuty])
        {
            PlayerInfo[playerid][pFacDuty] = 1;
            SetPlayerColor(playerid, TRANSPARENT_BLUE);
            format(string, sizeof(string), "* %s grabs their badge, gun and mp5 from the locker.", RPN(playerid));
            SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
            GiveZaiatWeapon(playerid, 29, 500);
            GiveZaiatWeapon(playerid, 24, 200);
            SetPlayerArmour(playerid, 100);
        }
        else
        {
            PlayerInfo[playerid][pFacDuty] = 0;
            SetPlayerColor(playerid, TRANSPARENT_WHITE);
            SetPlayerArmour(playerid, 0);
            format(string, sizeof(string), "* %s places their badge in the locker.", RPN(playerid));
            SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        }
    }
    return 1;
}
Oh tks xD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)