PDA

View Full Version : Megaphone Help


lramos15
30/10/2013, 08:47 PM
I made a megaphone command
CMD:m(playerid,params[])
{
new Float:x,Float:y,Float:z,megaphonemessage[500];
new MeagaphonefID = PlayerInfo[playerid][Faction];
if(MegaphonefID == 1 && PlayerInfo[playerid][Rank] == 1) {
for(new i=1;i<MAX_VEHICLES;i++)
{
GetVehiclePos(FactionCars[factionid][i],x,y,z);
if(IsPlayerInRangeOfPoint(playerid,5.0,x,y,z)) {
format(megaphonemessage,500,"[%s %s:o< %s ]",FactionInfo[1][rank1],GetName(playerid),megaphonemessage);
ProxDetector(100.0, playerid, megaphonemessage,COLOR_YELLOW);
}else{
SendClientmessage(playerid,COLOR_RED,"You are not in range of any Faction vehicles.");
}
return 1;
}

but when I run it I get
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(238) : error 017: undefined symbol "LoadAllFactions"
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2323) : error 017: undefined symbol "MegaphonefID"
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2326) : error 032: array index out of bounds (variable "FactionCars")
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2330) : warning 217: loose indentation
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2331) : error 017: undefined symbol "SendClientmessage"
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2333) : warning 217: loose indentation
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2336) : warning 217: loose indentation
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2336) : error 029: invalid expression, assumed zero
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2336) : error 017: undefined symbol "LoadAllFactions"
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2337) : error 029: invalid expression, assumed zero
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2337) : error 017: undefined symbol "LoadAllFactions"
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2351) : warning 225: unreachable code
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2351) : error 029: invalid expression, assumed zero
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2351) : error 017: undefined symbol "LoadFactionData"
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2352) : error 029: invalid expression, assumed zero
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2352) : error 017: undefined symbol "LoadFactionData"
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2354) : error 017: undefined symbol "name"
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2354) : error 017: undefined symbol "factionids"
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2355) : error 017: undefined symbol "name"
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2355) : error 017: undefined symbol "factionids"
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2356) : error 017: undefined symbol "name"
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2356) : error 017: undefined symbol "factionids"
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2357) : error 017: undefined symbol "name"
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2357) : error 017: undefined symbol "factionids"
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2358) : error 017: undefined symbol "name"
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2358) : error 017: undefined symbol "factionids"
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2359) : error 017: undefined symbol "name"
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2359) : error 017: undefined symbol "factionids"
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2360) : error 017: undefined symbol "name"
C:\Users\logan_000\Desktop\SAMP Server\gamemodes\lramos15.pwn(2360) : error 017: undefined symbol "factionids"

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


26 Errors.

practically everything under it becomes an error.
EDIT: Also how do I get the megaphone to work with ranks 1 -> 10 right now that is scripted only for Rank 1

EiresJason
30/10/2013, 08:54 PM
--------------------------- ---------------- -------------------------------- */
CMD:m(playerid,params[])
{
new Float:x,Float:y,Float:z,megaphonemessage[128]; //changed too 128 as 500 is inefficient.
new MeagaphonefID = PlayerInfo[playerid][Faction];
if(MegaphonefID == 1 && PlayerInfo[playerid][Rank] > 0 && PlayerInfo[playerid][Rank] < 11)
{
for(new i=1;i<MAX_VEHICLES;i++)
{
GetVehiclePos(FactionCars[MeagaphonefID][i],x,y,z);
if(IsPlayerInRangeOfPoint(playerid,5.0,x,y,z))
{
format(megaphonemessage,500,"[%s %s:o< %s ]",FactionInfo[MeagaphonefID][rank1],GetName(playerid),megaphonemessage);
ProxDetector(100.0, playerid, megaphonemessage,COLOR_YELLOW);
}
}
}
else SendClientmessage(playerid,COLOR_RED,"You are not in range of any Faction vehicles.");
return 1;
}


E: Updated.

lramos15
30/10/2013, 10:06 PM
always displays me as Rank 1, if not near cruiser gives me unknown command and message doesnt show

RayDcosta
31/10/2013, 07:09 AM
sir, are you trying to compile the megaphone command without defining the related variables?
if so, it will definitely show an error.

lramos15
31/10/2013, 10:07 AM
There's no errors during compiling. When you test the script it doesn't work. You type /m <message> and it always returns me as faction rank 1 and if I'm not near a cruiser it returns unknown command

MrTinder
31/10/2013, 10:08 AM
CMD:m(playerid,params[])
{
new Float:x,Float:y,Float:z,megaphonemessage[128]; //changed too 128 as 500 is inefficient.
new MeagaphonefID = PlayerInfo[playerid][Faction];
if(MegaphonefID == 1 && PlayerInfo[playerid][Rank] > 0 && PlayerInfo[playerid][Rank] < 11)
{
for(new i=1;i<MAX_VEHICLES;i++)
{
GetVehiclePos(FactionCars[MeagaphonefID][i],x,y,z);
if(IsPlayerInRangeOfPoint(playerid,5.0,x,y,z))
{
format(megaphonemessage,500,"[%s %s:o< %s ]",PlayerInfo[playerid][Rank],GetName(playerid),megaphonemessage);
ProxDetector(100.0, playerid, megaphonemessage,COLOR_YELLOW);
}
}
}
else SendClientmessage(playerid,COLOR_RED,"You are not in range of any Faction vehicles.");
return 1;
}

lramos15
31/10/2013, 06:58 PM
So I fixed everything but the error unknown command
CMD:m(playerid,params[])
{
new Float:x,Float:y,Float:z,megaphonemessage[128];
new MFid = PlayerInfo[playerid][Faction];
if(sscanf(params,"s[128]",megaphonemessage)) return SendClientMessage(playerid,COLOR_RED, "Usage: /m [message]");
if(PlayerInfo[playerid][Rank] <= 0) return SendClientMessage(playerid,COLOR_RED, "You are not in a Faction");
if(MFid != 1) return SendClientMessage(playerid,COLOR_RED, "You are not in a legal faction");
if(MFid == 1 && PlayerInfo[playerid][Rank] == 1)
{
for(new i=1;i<MAX_VEHICLES;i++)
{
GetVehiclePos(FactionCars[1][i],x,y,z);
if(IsPlayerInRangeOfPoint(playerid,5.0,x,y,z))
{
format(megaphonemessage,128,"[%s %s:o< %s ]",FactionInfo[1][rank1],GetName(playerid),megaphonemessage);
ProxDetector(100.0, playerid, megaphonemessage,COLOR_YELLOW);
}
}
}
else if(MFid == 1 && PlayerInfo[playerid][Rank] == 2)
{
for(new i=1;i<MAX_VEHICLES;i++)
{
GetVehiclePos(FactionCars[1][i],x,y,z);
if(IsPlayerInRangeOfPoint(playerid,5.0,x,y,z))
{
format(megaphonemessage,128,"[%s %s:o< %s ]",FactionInfo[1][rank2],GetName(playerid),megaphonemessage);
ProxDetector(100.0, playerid, megaphonemessage,COLOR_YELLOW);
}
}
}
else if(MFid == 1 && PlayerInfo[playerid][Rank] == 3)
{
for(new i=1;i<MAX_VEHICLES;i++)
{
GetVehiclePos(FactionCars[1][i],x,y,z);
if(IsPlayerInRangeOfPoint(playerid,5.0,x,y,z))
{
format(megaphonemessage,128,"[%s %s:o< %s ]",FactionInfo[1][rank3],GetName(playerid),megaphonemessage);
ProxDetector(100.0, playerid, megaphonemessage,COLOR_YELLOW);
}
}
}
else if(MFid == 1 && PlayerInfo[playerid][Rank] == 4)
{
for(new i=1;i<MAX_VEHICLES;i++)
{
GetVehiclePos(FactionCars[1][i],x,y,z);
if(IsPlayerInRangeOfPoint(playerid,5.0,x,y,z))
{
format(megaphonemessage,128,"[%s %s:o< %s ]",FactionInfo[1][rank4],GetName(playerid),megaphonemessage);
ProxDetector(100.0, playerid, megaphonemessage,COLOR_YELLOW);
}
}
}
else if(MFid == 1 && PlayerInfo[playerid][Rank] == 5)
{
for(new i=1;i<MAX_VEHICLES;i++)
{
GetVehiclePos(FactionCars[1][i],x,y,z);
if(IsPlayerInRangeOfPoint(playerid,5.0,x,y,z))
{
format(megaphonemessage,128,"[%s %s:o< %s ]",FactionInfo[1][rank5],GetName(playerid),megaphonemessage);
ProxDetector(100.0, playerid, megaphonemessage,COLOR_YELLOW);
}
}
}
else if(MFid == 1 && PlayerInfo[playerid][Rank] == 6)
{
for(new i=1;i<MAX_VEHICLES;i++)
{
GetVehiclePos(FactionCars[1][i],x,y,z);
if(IsPlayerInRangeOfPoint(playerid,5.0,x,y,z))
{
format(megaphonemessage,128,"[%s %s:o< %s ]",FactionInfo[1][rank6],GetName(playerid),megaphonemessage);
ProxDetector(100.0, playerid, megaphonemessage,COLOR_YELLOW);
}
}
}
else if(MFid == 1 && PlayerInfo[playerid][Rank] == 7)
{
for(new i=1;i<MAX_VEHICLES;i++)
{
GetVehiclePos(FactionCars[1][i],x,y,z);
if(IsPlayerInRangeOfPoint(playerid,5.0,x,y,z))
{
format(megaphonemessage,128,"[%s %s:o< %s ]",FactionInfo[1][rank7],GetName(playerid),megaphonemessage);
ProxDetector(100.0, playerid, megaphonemessage,COLOR_YELLOW);
}
}
}
else if(MFid == 1 && PlayerInfo[playerid][Rank] == 8)
{
for(new i=1;i<MAX_VEHICLES;i++)
{
GetVehiclePos(FactionCars[1][i],x,y,z);
if(IsPlayerInRangeOfPoint(playerid,5.0,x,y,z))
{
format(megaphonemessage,128,"[%s %s:o< %s ]",FactionInfo[1][rank8],GetName(playerid),megaphonemessage);
ProxDetector(100.0, playerid, megaphonemessage,COLOR_YELLOW);
}
}
}
else if(MFid == 1 && PlayerInfo[playerid][Rank] == 9)
{
for(new i=1;i<MAX_VEHICLES;i++)
{
GetVehiclePos(FactionCars[1][i],x,y,z);
if(IsPlayerInRangeOfPoint(playerid,5.0,x,y,z))
{
format(megaphonemessage,128,"[%s %s:o< %s ]",FactionInfo[1][rank9],GetName(playerid),megaphonemessage);
ProxDetector(100.0, playerid, megaphonemessage,COLOR_YELLOW);
}
}
}
else if(MFid == 1 && PlayerInfo[playerid][Rank] == 10)
{
for(new i=1;i<MAX_VEHICLES;i++)
{
GetVehiclePos(FactionCars[1][i],x,y,z);
if(IsPlayerInRangeOfPoint(playerid,5.0,x,y,z))
{
format(megaphonemessage,128,"[%s %s:o< %s ]",FactionInfo[1][rank10],GetName(playerid),megaphonemessage);
ProxDetector(100.0, playerid, megaphonemessage,COLOR_YELLOW);
}
}
}
else
{
SendClientMessage(playerid,COLOR_RED,"You are not in range of any faction vehicles");
}
return 1;
}
I do /m [message] it says it if Im near a cruiser but also gives me Server: UNKNOWN Command no matter what and if I'm not near a cruiser it doesnt say Im not near it just says SERVER: UNKNOWN COMMAND

lramos15
02/11/2013, 08:28 PM
bump