PDA

View Full Version : compiler error


crukk11
12/02/2017, 06:24 AM
how to add this code
COMMAND:agiveweapon(playerid, params[])
{
if(!logged[playerid])
return SendClientMessage(playerid, COLOR_BRIGHTRED, "You must be logged in!");

if(PlayerInfo[playerid][pAdmin] < 1)
return SendClientMessage(playerid, COLOR_BRIGHTRED, "You are not allowed to use that command!");

new
targetid = INVALID_PLAYER_ID,
weaponid,
ammo;

if(sscanf(params, "uii", targetid, weaponid ammo))
return SendClientMessage(playerid, COLOR_LIGHTBLUE, "USAGE: /agiveweapon [id] [arme] [munitions]");

if(!IsPlayerConnected(targetid))
{
format(string, sizeof(string), "ID:%d is not an active player.", targetid);
SendClientMessage(playerid, COLOR_BRIGHTRED, string);
return 1;
}

new
targetName[MAX_PLAYER_NAME],
weaponName[32];

GetPlayerName(targetid, targetName, sizeof targetName);
GetWeaponName(weaponid, weaponName, sizeof weaponName);

GivePlayerWeapon(targetid, weaponid, ammo);

format(string, sizeof(string), "You have given %s a %d with %d ammo.", targetName, weaponName, ammo);
SendClientMessage(playerid, COLOR_ORANGE, string);
return 1;
}

i compile it and i get error like this

C:\Users\Cyber\Desktop\SSSS\GL.pwn(1857) : error 017: undefined symbol "logged"
C:\Users\Cyber\Desktop\SSSS\GL.pwn(1857) : warning 215: expression has no effect
C:\Users\Cyber\Desktop\SSSS\GL.pwn(1857) : error 001: expected token: ";", but found "]"
C:\Users\Cyber\Desktop\SSSS\GL.pwn(1857) : error 029: invalid expression, assumed zero
C:\Users\Cyber\Desktop\SSSS\GL.pwn(1857) : fatal error 107: too many error messages on one line

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


4 Errors.

or how to short this code to zcmd code
crukk11 is online now Add to crukk11's Reputation Report Post
crukk11 is online now Add to crukk11's Reputation Report Post

SyS
12/02/2017, 06:36 AM
You just copy pasted the code to your script without declaring variables. The variable logged can be declared as global array of MAX_PLAYERS (http://wiki.sa-mp.com/wiki/MAX_PLAYERS)with bool tag.And set it as true on the part login confirms (probably a dialog's response in which you checks (http://wiki.sa-mp.com/wiki/Control_Structures) player types correct password (http://wiki.sa-mp.com/wiki/Strcmp)). And also reset this variable on player's disconnection (http://wiki.sa-mp.com/wiki/OnPlayerDisconnect) too.
Start referring from here (http://wiki.sa-mp.com/wiki/Scripting_Basics)

crukk11
12/02/2017, 08:07 AM
it means

crukk11
12/02/2017, 08:09 AM
and how to short the code to zcmd code