Making a weapon command, lots of errors -
biltong - 27.02.2010
Ok so I'm using zcmd and my code goes like
pawn Код:
zcmd(weap,playerid,params[])
{
new weapon;
if(!sscanf(params,"s",weapon))
{
switch(weapon)
{
case uzi: GivePlayerWeapon(playerid,28,500);
case microsmg: GivePlayerWeapon(playerid,28,500);
case m4: GivePlayerWeapon(playerid,31,500);
case sniper: GivePlayerWeapon(playerid,34,500);
case minigun: if(IsPlayerLuxAdmin(playerid))
{
GivePlayerWeapon(playerid,38,1500);
}
case knife: GivePlayerWeapon(playerid,4,1);
}
return 1;
}
else SendClientMessage(playerid,COLOR_RED,"USAGE: /weap [weapon name]");
return 1;
}
Yet when I try compile, I get told
Код:
G:\Program Files\Rockstar Games\SA-MP Server 0.3a\gamemodes\hydra.pwn(1094) : error 017: undefined symbol "uzi"
G:\Program Files\Rockstar Games\SA-MP Server 0.3a\gamemodes\hydra.pwn(1095) : error 017: undefined symbol "microsmg"
G:\Program Files\Rockstar Games\SA-MP Server 0.3a\gamemodes\hydra.pwn(1096) : error 017: undefined symbol "m4"
G:\Program Files\Rockstar Games\SA-MP Server 0.3a\gamemodes\hydra.pwn(1097) : error 017: undefined symbol "sniper"
G:\Program Files\Rockstar Games\SA-MP Server 0.3a\gamemodes\hydra.pwn(1098) : error 017: undefined symbol "minigun"
G:\Program Files\Rockstar Games\SA-MP Server 0.3a\gamemodes\hydra.pwn(1102) : error 017: undefined symbol "knife"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
6 Errors.
I see that you're not allowed to use words in cases, but I don't know how to fix it. Help please
Re: Making a weapon command, lots of errors -
ReactionGameServers - 27.02.2010
change them to case 1, case 2, case 3 ect.
Re: Making a weapon command, lots of errors -
biltong - 27.02.2010
My aim was for people to be able to give the name of the weapon to spawn it instead of a number, that's why I did it like that.
Re: Making a weapon command, lots of errors -
ReactionGameServers - 27.02.2010
define the words to number then
#define Uzi 1
#define Sniper 1
ect
Re: Making a weapon command, lots of errors -
biltong - 27.02.2010
Sorry, but I have no idea what you mean there
Re: Making a weapon command, lots of errors -
biltong - 03.03.2010
bump
Re: Making a weapon command, lots of errors -
02manchestera - 03.03.2010
if you look at the top of your gm script you will see some codes like this
make a new #define like
Код:
#define uzi
#define sniper
#define minigun
#define microsmg
#define m4
at that at the top of your gm script
Re: Making a weapon command, lots of errors -
Miguel - 03.03.2010
pawn Код:
zcmd(weap, playerid, params[])
{
new
weapname[10];
if(sscanf(params, "s", weapname)) return SendClientMessage(playerid, COLOR, "USAGE: /weap [weapon name]");
else if(strcmp(weapname, "uzi", true) == 0) return GivePlayerWeapon(playerid, 28, 500);
else if(strcmp(weapname, "microsmg", true) == 0) return GivePlayerWeapon(playerid, 28, 500);
else if(strcmp(weapname, "m4", true) == 0) return GivePlayerWeapon(playerid, 31, 500);
else if(strcmp(weapname, "sniper", true) == 0) return GivePlayerWeapon(playerid, 34, 500);
else if(strcmp(weapname, "knife", true) == 0) return GivePlayerWeapon(playerid, 4, 1);
else if(strcmp(weapname, "minigun", true) == 0)
{
if(IsPlayerLuxAdmin(playerid)) return GivePlayerWeapon(playerid, 38, 1500);
else return SendClientMessage(playerid, COLOR, "You're not allowed to use that weapon!");
}
else SendClientMessage(playerid, COLOR_RED, "Invalid weapon name!");
return 1;
}
Re: Making a weapon command, lots of errors -
biltong - 03.03.2010
Thanks, that code works perfectly