/callsign help | +rep
#1

i've made a command for /callsign,
i made it so it checks to see if the player isacop and if he is it allows him to attach a callsign, i did this and went in game to test and i made myself LSPD, and did /callsign and it just said the error message of You're not a cop. im confused and need help. thank you.

Код:
CMD:callsign(playerid, params[])
{
    new vehicleid;
    vehicleid = GetPlayerVehicleID(playerid);
	new string[32];
	if(IsPlayerInVehicle(playerid)) return SendClientMessageEx(playerid, COLOR_GREY, "You're not in a vehicle.");
	if(IsACop(playerid) || IsALVMPDCop(playerid)
		return SendClientMessageEx(playerid, COLOR_GREY, "You must be a police officer.");
	if (IsACopCar(vehicleid))
	    return SendClientMessageEx(playerid, COLOR_GREY, "You must be inside a police cruiser.");
	if(vehiclecallsign[GetPlayerVehicleID(playerid)] == 1)
	{
 		Delete3DTextLabel(vehicle3Dtext[vehicleid]);
	    vehiclecallsign[vehicleid] = 0;
	    SendClientMessage(playerid, COLOR_RED, "Callsign removed.");
	    return 1;
	}
	if(sscanf(params, "s[32]",string)) return SendClientMessageEx(playerid, COLOR_GREY, "You must enter a callsign.");
	if(vehiclecallsign[GetPlayerVehicleID(playerid)] == 0)
	{
		vehicle3Dtext[vehicleid] = Create3DTextLabel(string, COLOR_WHITE, 0.0, 0.0, 0.0, 10.0, 0, 1);
		Attach3DTextLabelToVehicle(vehicle3Dtext[vehicleid], vehicleid, 0.0, -2.8, 0.0);
		vehiclecallsign[vehicleid] = 1;
	}
	return 1;
}
Код:
IsACop(playerid)
{
	if(IsPlayerConnected(playerid))
	{
		new leader = PlayerInfo[playerid][pLeader];
		new member = PlayerInfo[playerid][pMember];
		if(member==1 || member==2 || member== 3 || member==7 || member==11 || member==13 || member==18 || member==19)
		{
			return 1;
		}
		else if(leader==1 || leader==2 || leader == 3 || leader==7 || leader==11 || leader==13 || leader==18 || leader==19)
		{
			return 1;
		}
 	}
	return 0;
}
Код:
IsACopCar(carid)
{
	for(new v = 0; v < sizeof(LSPDVehicles); v++)
	{
	    if(carid == LSPDVehicles[v]) return 1;
	}
	return 0;
}
Reply
#2

Not sure if it will fix the problem but,
pawn Код:
if(IsACop(playerid) || IsALVMPDCop(playerid)
        return SendClientMessageEx(playerid, COLOR_GREY, "You must be a police officer.");
is missing a ) at the end of if(..... || IsALVMPDCop(playerid))

pawn Код:
if(IsACop(playerid) || IsALVMPDCop(playerid)) // <----
        return SendClientMessageEx(playerid, COLOR_GREY, "You must be a police officer.");
Reply
#3

Quote:
Originally Posted by liquor
Посмотреть сообщение
Not sure if it will fix the problem but,
pawn Код:
if(IsACop(playerid) || IsALVMPDCop(playerid)
        return SendClientMessageEx(playerid, COLOR_GREY, "You must be a police officer.");
is missing a ) at the end of if(..... || IsALVMPDCop(playerid))

pawn Код:
if(IsACop(playerid) || IsALVMPDCop(playerid)) // <----
        return SendClientMessageEx(playerid, COLOR_GREY, "You must be a police officer.");
Tried that and it didnt work, its still saying i must be a police officer.
Reply
#4

Quote:

if(!IsACop(playerid) || !IsALVMPDCop(playerid)
return SendClientMessageEx(playerid, COLOR_GREY, "You must be a police officer.");
if (!IsACopCar(vehicleid))
return SendClientMessageEx(playerid, COLOR_GREY, "You must be inside a police cruiser.");

Try that
Reply
#5

All you have to do is adding "!", which means IsCOP != 1


PHP код:
if(!IsACop(playerid) || !IsALVMPDCop(playerid)
        return 
SendClientMessageEx(playeridCOLOR_GREY"You must be a police officer."); 
Reply
#6

Okay thanks for that part so now i go in game and test i do /callsign STAFF-1 lets say and it just puts three weird letters at the spot.
Reply
#7

Do you have
new Text3D:vehicle3Dtext[MAX_VEHICLES];
new vehiclecallsign[MAX_VEHICLES];
anywhere?
Reply
#8

Try this
pawn Код:
CMD:callsign(playerid, params[])
{
    if(IsPlayerInVehicle(playerid)) return SendClientMessageEx(playerid, COLOR_GREY, "You're not in a vehicle.");
    if(!IsACop(playerid) || !IsALVMPDCop(playerid) return SendClientMessageEx(playerid, COLOR_GREY, "You must be a police officer.");

    new vehicleid = GetPlayerVehicleID(playerid);
   
    if(!IsACopCar(vehicleid)) return SendClientMessageEx(playerid, COLOR_GREY, "You must be inside a police cruiser.");
   
    if(vehiclecallsign[GetPlayerVehicleID(playerid)] == 1)
    {
        Delete3DTextLabel(vehicle3Dtext[vehicleid]);
        vehiclecallsign[vehicleid] = 0;
        SendClientMessage(playerid, COLOR_RED, "Callsign removed.");
    }
    else
    {
        new string[32];
        if(sscanf(params, "s[32]",string)) return SendClientMessageEx(playerid, COLOR_GREY, "You must enter a callsign.");

        vehicle3Dtext[vehicleid] = Create3DTextLabel(string, COLOR_WHITE, 0.0, 0.0, 0.0, 10.0, 0, 1);
        Attach3DTextLabelToVehicle(vehicle3Dtext[vehicleid], vehicleid, 0.0, -2.8, 0.0);
        vehiclecallsign[vehicleid] = 1;
    }
    return 1;
}
I optimized it a bit
Reply
#9

Quote:
Originally Posted by XVlaDX
Посмотреть сообщение
Do you have
new Text3D:vehicle3Dtext[MAX_VEHICLES];
new vehiclecallsign[MAX_VEHICLES];
anywhere?
yes i do.
Reply
#10

Tried both thing,
still did this

I added a format to it. and still does it. here is the code right now.

Код:
CMD:callsign(playerid, params[])
{
    new vehicleid;
    vehicleid = GetPlayerVehicleID(playerid);
    new string[32];
    format(string,sizeof(string), "%s",params);
	if(IsPlayerInVehicle(playerid)) return SendClientMessageEx(playerid, COLOR_GREY, "You're not in a vehicle.");
	if(!IsAGovernmentFaction(playerid) || !IsALVMPDCop(playerid))
		return SendClientMessageEx(playerid, COLOR_GREY, "You must be a police officer.");
	if (!IsACopCar(vehicleid))
		return SendClientMessageEx(playerid, COLOR_GREY, "You must be inside a police cruiser.");
	if(vehiclecallsign[GetPlayerVehicleID(playerid)] == 1)
	{
 		Delete3DTextLabel(vehicle3Dtext[vehicleid]);
	    vehiclecallsign[vehicleid] = 0;
	    SendClientMessage(playerid, COLOR_RED, "Callsign removed.");
	    return 1;
	}
	if(sscanf(params, "s[32]",string)) return SendClientMessageEx(playerid, COLOR_GREY, "You must enter a callsign.");
	if(vehiclecallsign[GetPlayerVehicleID(playerid)] == 0)
	{
		vehicle3Dtext[vehicleid] = Create3DTextLabel(string, COLOR_WHITE, 0.0, 0.0, 0.0, 10.0, 0, 1);
		Attach3DTextLabelToVehicle(vehicle3Dtext[vehicleid], vehicleid, -0.7, -1.9, -0.3);
		vehiclecallsign[vehicleid] = 1;
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)