How to fix this cmd?
#1

whenever i use /m within a vehicle while on law enforcement faction,nothing happens.

Код:
	if(strcmp(cmd, "/megaphone", true) == 0 || strcmp(cmd, "/m", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        new type = FactionInfo[PlayerInfo[playerid][pMember]][FactionType];
			new tmpcar = GetPlayerVehicleID(playerid);
			GetPlayerName(playerid, sendername, sizeof(sendername));
			new length = strlen(cmdtext);
			while ((idx < length) && (cmdtext[idx] <= ' '))
			{
				idx++;
			}
			new offset = idx;
			new result[64];
			while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
			{
				result[idx - offset] = cmdtext[idx];
				idx++;
			}
			result[idx - offset] = EOS;
			if(!strlen(result))
			{
				SendClientMessage(playerid, COLOR_WHITE, "USAGE: (/m)egaphone [megaphone chat]");
				return 1;
			}
			if(IsACop(playerid) || PlayerInfo[playerid][pMember] == 4 || PlayerInfo[playerid][pLeader] == 4|| IsASoldier(playerid) || IsAnAgent(playerid) || IsAMedic(playerid))
			{
				if(!IsACopCar(tmpcar) && !IsAnAmbulance(tmpcar) && !IsANGCar(tmpcar))
				{
					SendClientMessage(playerid, COLOR_GRAD2, "   You are not in a Government vehicle !");
					return 1;
				}
				else if(IsACop(type))
				{
					format(string, sizeof(string), "[Officer %s:o< %s]", sendername, result);
					ProxDetector(60.0, playerid, string,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
				}
				else if(IsAnAgent(playerid))
				{
					format(string, sizeof(string), "[Agent %s:o< %s]", sendername, result);
					ProxDetector(60.0, playerid, string,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
				}
				else if(IsAMedic(playerid))
				{
				    format(string, sizeof(string), "[Doctor %s:o< %s]", sendername, result);
				    ProxDetector(60.0, playerid, string,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
				}
				else if(IsASoldier(playerid))
				{
				    format(string, sizeof(string), "[Soldier %s:o< %s]", sendername, result);
				    ProxDetector(60.0, playerid, string,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
				}
			}
			else
			{
			    SendClientMessage(playerid, COLOR_GRAD2, "   You are not part of a Faction !");
				return 1;
			}
		}
		return 1;
Reply
#2

I think this:
PHP код:
if(!IsACopCar(tmpcar) && !IsAnAmbulance(tmpcar) && !IsANGCar(tmpcar)) 
Should be:
PHP код:
if(!IsACopCar(tmpcar) || !IsAnAmbulance(tmpcar) || !IsANGCar(tmpcar)) 
Because: First means: "If tmpcar is a not cop car and not an ambulance and not a ng car..."
Second: "If tmpcar is not a cop car or an ambulance or a ng car..."
PS: Use YCMD / PawnCMD because they are faster at commands. Also use sscanf plugin by ****** because it works veryy very good with them.
Reply
#3

PHP код:
CMD:m(playeridparams[])
{
    if(
strcmp(cmd"/megaphone"true) == || strcmp(cmd"/m"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            new 
type FactionInfo[PlayerInfo[playerid][pMember]][FactionType];
            new 
tmpcar GetPlayerVehicleID(playerid);
            
GetPlayerName(playeridsendernamesizeof(sendername));
            new 
length strlen(cmdtext);
            while ((
idx length) && (cmdtext[idx] <= ' '))
            {
                
idx++;
            }
            new 
offset idx;
            new 
result[64];
            while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
            {
                
result[idx offset] = cmdtext[idx];
                
idx++;
            }
            
result[idx offset] = EOS;
            if(!
strlen(result))
            {
                
SendClientMessage(playeridCOLOR_WHITE"USAGE: (/m)egaphone [megaphone chat]");
                return 
1;
            }
            if(
IsACop(playerid) || PlayerInfo[playerid][pMember] == || PlayerInfo[playerid][pLeader] == 4|| IsASoldier(playerid) || IsAnAgent(playerid) || IsAMedic(playerid))
            {
                if(!
IsACopCar(tmpcar) && !IsAnAmbulance(tmpcar) && !IsANGCar(tmpcar))
                {
                    
SendClientMessage(playeridCOLOR_GRAD2"   You are not in a Government vehicle !");
                    return 
1;
                }
                else if(
IsACop(type))
                {
                    
format(stringsizeof(string), "[Officer %s:o< %s]"sendernameresult);
                    
ProxDetector(60.0playeridstring,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
                }
                else if(
IsAnAgent(playerid))
                {
                    
format(stringsizeof(string), "[Agent %s:o< %s]"sendernameresult);
                    
ProxDetector(60.0playeridstring,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
                }
                else if(
IsAMedic(playerid))
                {
                    
format(stringsizeof(string), "[Doctor %s:o< %s]"sendernameresult);
                    
ProxDetector(60.0playeridstring,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
                }
                else if(
IsASoldier(playerid))
                {
                    
format(stringsizeof(string), "[Soldier %s:o< %s]"sendernameresult);
                    
ProxDetector(60.0playeridstring,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
                }
            }
            else
            {
                
SendClientMessage(playeridCOLOR_GRAD2"   You are not part of a Faction !");
                return 
1;
            }
        }
        return 
1;

Reply
#4

Quote:
Originally Posted by n00blek
Посмотреть сообщение
PHP код:
CMD:m(playeridparams[])
{
    if(
strcmp(cmd"/megaphone"true) == || strcmp(cmd"/m"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            new 
type FactionInfo[PlayerInfo[playerid][pMember]][FactionType];
            new 
tmpcar GetPlayerVehicleID(playerid);
            
GetPlayerName(playeridsendernamesizeof(sendername));
            new 
length strlen(cmdtext);
            while ((
idx length) && (cmdtext[idx] <= ' '))
            {
                
idx++;
            }
            new 
offset idx;
            new 
result[64];
            while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
            {
                
result[idx offset] = cmdtext[idx];
                
idx++;
            }
            
result[idx offset] = EOS;
            if(!
strlen(result))
            {
                
SendClientMessage(playeridCOLOR_WHITE"USAGE: (/m)egaphone [megaphone chat]");
                return 
1;
            }
            if(
IsACop(playerid) || PlayerInfo[playerid][pMember] == || PlayerInfo[playerid][pLeader] == 4|| IsASoldier(playerid) || IsAnAgent(playerid) || IsAMedic(playerid))
            {
                if(!
IsACopCar(tmpcar) && !IsAnAmbulance(tmpcar) && !IsANGCar(tmpcar))
                {
                    
SendClientMessage(playeridCOLOR_GRAD2"   You are not in a Government vehicle !");
                    return 
1;
                }
                else if(
IsACop(type))
                {
                    
format(stringsizeof(string), "[Officer %s:o< %s]"sendernameresult);
                    
ProxDetector(60.0playeridstring,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
                }
                else if(
IsAnAgent(playerid))
                {
                    
format(stringsizeof(string), "[Agent %s:o< %s]"sendernameresult);
                    
ProxDetector(60.0playeridstring,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
                }
                else if(
IsAMedic(playerid))
                {
                    
format(stringsizeof(string), "[Doctor %s:o< %s]"sendernameresult);
                    
ProxDetector(60.0playeridstring,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
                }
                else if(
IsASoldier(playerid))
                {
                    
format(stringsizeof(string), "[Soldier %s:o< %s]"sendernameresult);
                    
ProxDetector(60.0playeridstring,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
                }
            }
            else
            {
                
SendClientMessage(playeridCOLOR_GRAD2"   You are not part of a Faction !");
                return 
1;
            }
        }
        return 
1;

Thanks mate.let me try
Reply
#5

@n00blek what the hell..... Are you a noob or what
OP: ignore n00blek's answer because he don't know what he is saying....
Reply
#6

Quote:
Originally Posted by 10MIN
Посмотреть сообщение
@n00blek what the hell..... Are you a noob or what
OP: ignore n00blek's answer because he don't know what he is saying....
So,do you know how to fix it?
Reply
#7

This:
Quote:
Originally Posted by 10MIN
Посмотреть сообщение
I think this:
PHP код:
if(!IsACopCar(tmpcar) && !IsAnAmbulance(tmpcar) && !IsANGCar(tmpcar)) 
Should be:
PHP код:
if(!IsACopCar(tmpcar) || !IsAnAmbulance(tmpcar) || !IsANGCar(tmpcar)) 
Because: First means: "If tmpcar is a not cop car and not an ambulance and not a ng car..."
Second: "If tmpcar is not a cop car or an ambulance or a ng car..."
PS: Use YCMD / PawnCMD because they are faster at commands. Also use sscanf plugin by ****** because it works veryy very good with them.
Reply
#8

Here you go buddy,

PHP код:
CMD:m(playerid)
{
    new 
type FactionInfo[PlayerInfo[playerid][pMember]][FactionType];
    new 
tmpcar GetPlayerVehicleID(playerid);
    
GetPlayerName(playeridsendernamesizeof(sendername));
    new 
length strlen(cmdtext);
    while ((
idx length) && (cmdtext[idx] <= ' '))
    {
        
idx++;
    }
    new 
offset idx;
    new 
result[64];
    while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
    {
        
result[idx offset] = cmdtext[idx];
        
idx++;
    }
    
result[idx offset] = EOS;
    if(!
strlen(result))
    {
        
SendClientMessage(playeridCOLOR_WHITE"USAGE: (/m)egaphone [megaphone chat]");
        return 
1;
    }
    if(
IsACop(playerid) || PlayerInfo[playerid][pMember] == || PlayerInfo[playerid][pLeader] == 4|| IsASoldier(playerid) || IsAnAgent(playerid) || IsAMedic(playerid))
    {
        if(!
IsACopCar(tmpcar) || !IsAnAmbulance(tmpcar) || !IsANGCar(tmpcar))
        {
            
SendClientMessage(playeridCOLOR_GRAD2"   You are not in a Government vehicle !");
            return 
1;
        }
        else if(
IsACop(type))
        {
            
format(stringsizeof(string), "[Officer %s:o< %s]"sendernameresult);
            
ProxDetector(60.0playeridstring,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
        }
        else if(
IsAnAgent(playerid))
        {
            
format(stringsizeof(string), "[Agent %s:o< %s]"sendernameresult);
            
ProxDetector(60.0playeridstring,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
            }
        else if(
IsAMedic(playerid))
        {
            
format(stringsizeof(string), "[Doctor %s:o< %s]"sendernameresult);
            
ProxDetector(60.0playeridstring,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
        }
        else if(
IsASoldier(playerid))
        {
            
format(stringsizeof(string), "[Soldier %s:o< %s]"sendernameresult);
            
ProxDetector(60.0playeridstring,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW,COLOR_YELLOW);
        }
    }
    else return 
SendClientMessage(playeridCOLOR_GRAD2"   You are not part of a Faction !");
}
CMD:megaphone(playerid)
{
    return 
cmd_m(playerid);

I don't know if it'll be fully functional (I haven't gone through the code). But, now it'll be easier to debug for you.

Also, Make sure you have zcmd included
PHP код:
#include <zcmd> 
.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)