Help me with the code please
#1

I'm trying to do backup command,
Now it's only for the police and I want make it for more few factions.
Can someone help me and fix the code that I give?

PHP код:
CMD:backup(playeridparams[])
{
    new 
string[128], Float:bkxFloat:bkyFloat:bkz;
    if(!
IsPlayerLoggedIn(playerid)) return SendClientMessage(playeridCOLOR_GREY"You need to login first before using any command.");
    if(!
IsACop(playerid) && !IsFBI(playerid) && !IsNG(playerid) && !IsCTU(playerid)&& !IsMedic(playerid)&& !IsFireman(playerid)) return SendClientMessage(playeridCOLOR_GREY"You are not a LEO.");
    if(!
PlayerInfo[playerid][pFacDuty]) return SendClientMessage(playeridCOLOR_GREY"You are not on duty.");
    
GetPlayerPos(playeridbkxbkybkz);
    
format(stringsizeof(string), "[Central Dispatch]: %s is requesting backup,his coordinates have been marked on the GPS."RPN(playerid));
    
SendCopMessage(COLOR_RADIOstring);
    foreach(
Playeri)
    {
        if(
IsACop(i))
        {
            
SetPlayerMarkerForPlayer(iplayeridCOLOR_BACKUP);
        }
    }
    return 
1;

Please Help me.
Reply
#2

Quote:
Originally Posted by V1Su4L
Посмотреть сообщение
I'm trying to do backup command,
Now it's only for the police and I want make it for more few factions.
Can someone help me and fix the code that I give?

PHP код:
CMD:backup(playeridparams[])
{
    new 
string[128], Float:bkxFloat:bkyFloat:bkz;
    if(!
IsPlayerLoggedIn(playerid)) return SendClientMessage(playeridCOLOR_GREY"You need to login first before using any command.");
    if(!
IsACop(playerid) && !IsFBI(playerid) && !IsNG(playerid) && !IsCTU(playerid)&& !IsMedic(playerid)&& !IsFireman(playerid)) return SendClientMessage(playeridCOLOR_GREY"You are not a LEO.");
    if(!
PlayerInfo[playerid][pFacDuty]) return SendClientMessage(playeridCOLOR_GREY"You are not on duty.");
    
GetPlayerPos(playeridbkxbkybkz);
    
format(stringsizeof(string), "[Central Dispatch]: %s is requesting backup,his coordinates have been marked on the GPS."RPN(playerid));
    
SendCopMessage(COLOR_RADIOstring);
    foreach(
Playeri)
    {
        if(
IsACop(i))
        {
            
SetPlayerMarkerForPlayer(iplayeridCOLOR_BACKUP);
        }
    }
    return 
1;

Please Help me.
here, you check if they're a LEO.
pawn Код:
if(!IsACop(playerid) && !IsFBI(playerid) && !IsNG(playerid) && !IsCTU(playerid)&& !IsMedic(playerid)&& !IsFireman(playerid))
if not, it'll return that message and STOP the command.
this means that for ppls who are not LEO's the code processing stops right here.
so you don't have to check it again in your "foreach".

just
pawn Код:
foreach(Player, i)
{
    SetPlayerMarkerForPlayer(i, playerid, COLOR_BACKUP);
}
will do
Reply
#3

Quote:
Originally Posted by CutX
Посмотреть сообщение
here, you check if they're a LEO.
pawn Код:
if(!IsACop(playerid) && !IsFBI(playerid) && !IsNG(playerid) && !IsCTU(playerid)&& !IsMedic(playerid)&& !IsFireman(playerid))
if not, it'll return that message and STOP the command.
this means that for ppls who are not LEO's the code processing stops right here.
so you don't have to check it again in your "foreach".

just
pawn Код:
foreach(Player, i)
{
    SetPlayerMarkerForPlayer(i, playerid, COLOR_BACKUP);
}
will do
I have this error:

PHP код:
warning 209: function "cmd_backup" should return a value
error 010
invalid function or declaration 
Reply
#4

Quote:
Originally Posted by osman2571
Посмотреть сообщение
CMD:backup(playerid, params[])
{
new string[128], Float:bkx, Float:bky, Float:bkz;
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(!IsACop(playerid) && !IsFBI(playerid) && !IsNG(playerid) && !IsCTU(playerid)&& !IsMedic(playerid)&& !IsFireman(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not a LEO.");
if(!PlayerInfo[playerid][pFacDuty]) return SendClientMessage(playerid, COLOR_GREY, "You are not on duty.");
GetPlayerPos(playerid, bkx, bky, bkz);
format(string, sizeof(string), "[Central Dispatch]: %s is requesting backup,his coordinates have been marked on the GPS.", RPN(playerid));
SendCopMessage(COLOR_RADIO, string);
foreach(Player, i)
{
if(IsACop(i))
{
SetPlayerMarkerForPlayer(i, playerid, COLOR_BACKUP);
}
return 1;
}

Try
26 errors.
Reply
#5

Quote:
Originally Posted by osman2571
Посмотреть сообщение
Код:
CMD:backup(playerid, params[])
{
	new string[128], Float:bkx, Float:bky, Float:bkz;
	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
	if(!IsACop(playerid) && !IsFBI(playerid) && !IsNG(playerid) && !IsCTU(playerid)&& !IsMedic(playerid)&& !IsFireman(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not a LEO.");
	if(!PlayerInfo[playerid][pFacDuty]) return SendClientMessage(playerid, COLOR_GREY, "You are not on duty.");
	GetPlayerPos(playerid, bkx, bky, bkz);
	format(string, sizeof(string), "[Central Dispatch]: %s is requesting backup,his coordinates have been marked on the GPS.", RPN(playerid));
	SendCopMessage(COLOR_RADIO, string);
	foreach(Player, i)
	{
		if(IsACop(i))
		{
			SetPlayerMarkerForPlayer(i, playerid, COLOR_BACKUP);
		}
	}
	}
	return 1;
}
I have warning and error:
PHP код:
warning 209: function "cmd_backup" should return a value
error 010
invalid function or declaration 
Reply
#6

Quote:
Originally Posted by osman2571
Посмотреть сообщение
Код:
CMD:backup(playerid, params[])
{
	new string[128], Float:bkx, Float:bky, Float:bkz;
	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
	if(!IsACop(playerid) && !IsFBI(playerid) && !IsNG(playerid) && !IsCTU(playerid) && !IsMedic(playerid) && !IsFireman(playerid))
	if(!PlayerInfo[playerid][pFacDuty]) return SendClientMessage(playerid, COLOR_GREY, "You are not on duty.");
	GetPlayerPos(playerid, bkx, bky, bkz);
	format(string, sizeof(string), "[Central Dispatch]: %s is requesting backup,his coordinates have been marked on the GPS.", RPN(playerid));
	SendCopMessage(COLOR_RADIO, string);
	foreach(Player, i)
	{
		if(IsACop(i))
		{
			SetPlayerMarkerForPlayer(i, playerid, COLOR_BACKUP);
		}
		else
		{
		    SendClientMessage(playerid, COLOR_GREY, "You are not a LEO.");
		}
	}
	return 1;
}
try this if not work i will send you fix in pm
it works only for the Police.
Reply
#7

Quote:
Originally Posted by osman2571
Посмотреть сообщение
Код:
CMD:backup(playerid, params[])
{
	new string[128], Float:bkx, Float:bky, Float:bkz;
	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
	if(!IsACop(playerid) && !IsFBI(playerid) && !IsNG(playerid) && !IsCTU(playerid) && !IsMedic(playerid) && !IsFireman(playerid))
	if(!PlayerInfo[playerid][pFacDuty]) return SendClientMessage(playerid, COLOR_GREY, "You are not on duty.");
	GetPlayerPos(playerid, bkx, bky, bkz);
	format(string, sizeof(string), "[Central Dispatch]: %s is requesting backup,his coordinates have been marked on the GPS.", RPN(playerid));
	SendCopMessage(COLOR_RADIO, string);
	foreach(Player, i)
	{
		if(!IsACop(i) && !IsFBI(i) && !IsNG(i) && !IsCTU(i) && !IsMedic(i) && !IsFireman(i))
		{
			SetPlayerMarkerForPlayer(i, playerid, COLOR_BACKUP);
		}
		else
		{
		    SendClientMessage(playerid, COLOR_GREY, "You are not a LEO.");
		}
	}
	return 1;
}
This will be for all factions
I'm in the army,
it's say that I'm not a LEO.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)