Error SAMP
#1

Ok guyz here is my problem

Код:
C:\Users\Dennis Laptop\Desktop\latw.pwn(1141) : warning 225: unreachable code
C:\Users\Dennis Laptop\Desktop\latw.pwn(1496) : error 017: undefined symbol "Player"
C:\Users\Dennis Laptop\Desktop\latw.pwn(1496) : error 017: undefined symbol "Player"
C:\Users\Dennis Laptop\Desktop\latw.pwn(1496) : warning 215: expression has no effect
C:\Users\Dennis Laptop\Desktop\latw.pwn(1496) : error 001: expected token: ";", but found "]"
C:\Users\Dennis Laptop\Desktop\latw.pwn(1496) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
and here the lines!

Код:
// Admin Commands
dcmd_givegun(playerid, params[]) // Level 2
{
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
new target, weaponid, string[128];
if(sscanf(params, "ud", target, weaponid)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /givegun [playerid/name] [weaponid]");
if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid player id!");
if(weaponid < 0 || weaponid > 46) return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid weapon ID! (0 - 46)");
GivePlayerWeapon(target, weaponid, 500);
format(string, sizeof(string), "Admin %s has given you a weapon!", PlayerName(playerid));
SendClientMessage(target, COLOR_LIGHTGREEN, string);
return 1;
}

dcmd_makeadmin(playerid, params[]) // Level 5
{
if(PlayerInfo[playerid][pAdmin] < 5 || !IsPlayerAdmin(playerid)) SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
new target, level, string[128];
if(sscanf(params, "ud", target, level)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /makeadmin [playerid/name] [0-5]");
if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid player id!");
PlayerInfo[target][pAdmin] = level;
format(string, sizeof(string), "Admin %s has given you Level %d Admin!", PlayerName(playerid), level);
SendClientMessage(target, COLOR_LIGHTGREEN, string);
foreach(Player, i)  // <--- error here
{
	if(PlayerInfo[i][pAdmin] >= 4)
	{
	    format(string, sizeof(string), "Admin %s has given %s level %d Admin!", PlayerName(playerid), PlayerName(target), level);
	    SendClientMessage(i, COLOR_LIGHTRED, string);
	}
}
return 1;
}
dcmd_setmoney(playerid, params[]) // Level 3
{
if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
new target, amount;
new string[128];
if(sscanf(params, "ud", target, amount)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /setmoney [playerid/name] [amount]");
if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid player id!");
PlayerInfo[target][pMoney] = amount;
ResetPlayerMoney(target);
new newmoney = PlayerInfo[target][pMoney];
GivePlayerMoney(target, newmoney);
format(string, sizeof(string), "Admin %s has set your money to %d !", PlayerName(playerid), newmoney);
SendClientMessage(target, COLOR_LIGHTGREEN, string);
foreach(Player, i)
{
	if (PlayerInfo[i][pAdmin] >= 1)
	{
	    format(string, sizeof(string), "Admin %s has set %s's money to %d !", PlayerName(playerid), PlayerName(target), amount);
	    SendClientMessage(i, COLOR_LIGHTRED, string);
	}
}
return 1;
}

dcmd_givemoney(playerid, params[]) // Level 3
{
if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
new target, money;
new string[128];
if(sscanf(params, "ud", target, money)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /givemoney [playerid/name] [amount]");
if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid player id!");
if(money < 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You can't givemoney below 0!");
GivePlayerMoney(target, money);
PlayerInfo[target][pMoney] += money;
format(string, sizeof(string), "Admin %s has given you %d !", PlayerName(playerid), money);
SendClientMessage(target, COLOR_LIGHTGREEN, string);
foreach(Player ,i)
{
	if(PlayerInfo[i][pAdmin] >=1)
	{
	    format(string, sizeof(string), "Admin %s has given %s %d !", PlayerName(playerid), PlayerName(target), money);
	    SendClientMessage(i, COLOR_LIGHTRED, string);
	}
}
return 1;
}
dcmd_kick(playerid, params[]) // Level 1
{
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
new user, reason[128], string[128];
if(sscanf(params, "us[128]", user, reason)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /kick [playerid/name] [reason]");
if(!IsPlayerConnected(user)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid player id!");
if(PlayerInfo[user][pAdmin] > PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid, COLOR_LIGHTRED, "You can't kick higher level Admins!");
format(reason, sizeof(reason), "%s", reason);
format(string, sizeof(string), "Admin %s has kicked %s, reason: %s", PlayerName(playerid), PlayerName(user), reason);
SendClientMessageToAll(COLOR_LIGHTRED, string);
Kick(user);
return 1;
}

dcmd_veh(playerid, params[]) // Level 3
{
if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
if( !strlen( params ) ) return SendClientMessage(playerid, COLOR_LIGHTRED, "/veh [name] or [modelid]");
new car = ReturnVehicleModelID(params);
if(!car) return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid vehicle model id!");
new Float:x,Float:y,Float:z,Float:a;
GetPlayerPos(playerid, x,y,z);
GetPlayerFacingAngle(playerid, a);
CreateVehicle(car, x+1, y+1, z, a, -1, -1, 500);
SendClientMessage(playerid, COLOR_LIGHTGREEN, "You've spawned a vehicle!");
return 1;
}
the error is on the foreach
Reply
#2

Update your foreach.inc to the latest version and it should be like:
pawn Код:
#include <a_samp>
#include <foreach>

// rest..

// Admin Commands
dcmd_givegun(playerid, params[]) // Level 2
{
    if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
    new target, weaponid, string[128];
    if(sscanf(params, "ud", target, weaponid)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /givegun [playerid/name] [weaponid]");
    if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid player id!");
    if(weaponid < 0 || weaponid > 46) return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid weapon ID! (0 - 46)");
    GivePlayerWeapon(target, weaponid, 500);
    format(string, sizeof(string), "Admin %s has given you a weapon!", PlayerName(playerid));
    SendClientMessage(target, COLOR_LIGHTGREEN, string);
    return 1;
}

dcmd_makeadmin(playerid, params[]) // Level 5
{
    if(PlayerInfo[playerid][pAdmin] < 5 || !IsPlayerAdmin(playerid)) SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
    new target, level, string[128];
    if(sscanf(params, "ud", target, level)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /makeadmin [playerid/name] [0-5]");
    if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid player id!");
    PlayerInfo[target][pAdmin] = level;
    format(string, sizeof(string), "Admin %s has given you Level %d Admin!", PlayerName(playerid), level);
    SendClientMessage(target, COLOR_LIGHTGREEN, string);
    foreach(new i : Player)  // <--- error here
    {
        if(PlayerInfo[i][pAdmin] >= 4)
        {
            format(string, sizeof(string), "Admin %s has given %s level %d Admin!", PlayerName(playerid), PlayerName(target), level);
            SendClientMessage(i, COLOR_LIGHTRED, string);
        }
    }
    return 1;
}
dcmd_setmoney(playerid, params[]) // Level 3
{
    if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
    new target, amount;
    new string[128];
    if(sscanf(params, "ud", target, amount)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /setmoney [playerid/name] [amount]");
    if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid player id!");
    PlayerInfo[target][pMoney] = amount;
    ResetPlayerMoney(target);
    new newmoney = PlayerInfo[target][pMoney];
    GivePlayerMoney(target, newmoney);
    format(string, sizeof(string), "Admin %s has set your money to %d !", PlayerName(playerid), newmoney);
    SendClientMessage(target, COLOR_LIGHTGREEN, string);
    foreach(new i : Player)
    {
        if (PlayerInfo[i][pAdmin] >= 1)
        {
            format(string, sizeof(string), "Admin %s has set %s's money to %d !", PlayerName(playerid), PlayerName(target), amount);
            SendClientMessage(i, COLOR_LIGHTRED, string);
        }
    }
    return 1;
}

dcmd_givemoney(playerid, params[]) // Level 3
{
    if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
    new target, money;
    new string[128];
    if(sscanf(params, "ud", target, money)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /givemoney [playerid/name] [amount]");
    if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid player id!");
    if(money < 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You can't givemoney below 0!");
    GivePlayerMoney(target, money);
    PlayerInfo[target][pMoney] += money;
    format(string, sizeof(string), "Admin %s has given you %d !", PlayerName(playerid), money);
    SendClientMessage(target, COLOR_LIGHTGREEN, string);
    foreach(new i : Player)
    {
        if(PlayerInfo[i][pAdmin] >=1)
        {
            format(string, sizeof(string), "Admin %s has given %s %d !", PlayerName(playerid), PlayerName(target), money);
            SendClientMessage(i, COLOR_LIGHTRED, string);
        }
    }
    return 1;
}
dcmd_kick(playerid, params[]) // Level 1
{
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
    new user, reason[128], string[128];
    if(sscanf(params, "us[128]", user, reason)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /kick [playerid/name] [reason]");
    if(!IsPlayerConnected(user)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid player id!");
    if(PlayerInfo[user][pAdmin] > PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid, COLOR_LIGHTRED, "You can't kick higher level Admins!");
    format(reason, sizeof(reason), "%s", reason);
    format(string, sizeof(string), "Admin %s has kicked %s, reason: %s", PlayerName(playerid), PlayerName(user), reason);
    SendClientMessageToAll(COLOR_LIGHTRED, string);
    Kick(user);
    return 1;
}

dcmd_veh(playerid, params[]) // Level 3
{
    if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
    if( !strlen( params ) ) return SendClientMessage(playerid, COLOR_LIGHTRED, "/veh [name] or [modelid]");
    new car = ReturnVehicleModelID(params);
    if(!car) return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid vehicle model id!");
    new Float:x,Float:y,Float:z,Float:a;
    GetPlayerPos(playerid, x,y,z);
    GetPlayerFacingAngle(playerid, a);
    CreateVehicle(car, x+1, y+1, z, a, -1, -1, 500);
    SendClientMessage(playerid, COLOR_LIGHTGREEN, "You've spawned a vehicle!");
    return 1;
}
About the line 1141, I assume you used return and after that you have code. Remove that return from there.
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Update your foreach.inc to the latest version and it should be like:
pawn Код:
#include <a_samp>
#include <foreach>

// rest..

// Admin Commands
dcmd_givegun(playerid, params[]) // Level 2
{
    if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
    new target, weaponid, string[128];
    if(sscanf(params, "ud", target, weaponid)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /givegun [playerid/name] [weaponid]");
    if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid player id!");
    if(weaponid < 0 || weaponid > 46) return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid weapon ID! (0 - 46)");
    GivePlayerWeapon(target, weaponid, 500);
    format(string, sizeof(string), "Admin %s has given you a weapon!", PlayerName(playerid));
    SendClientMessage(target, COLOR_LIGHTGREEN, string);
    return 1;
}

dcmd_makeadmin(playerid, params[]) // Level 5
{
    if(PlayerInfo[playerid][pAdmin] < 5 || !IsPlayerAdmin(playerid)) SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
    new target, level, string[128];
    if(sscanf(params, "ud", target, level)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /makeadmin [playerid/name] [0-5]");
    if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid player id!");
    PlayerInfo[target][pAdmin] = level;
    format(string, sizeof(string), "Admin %s has given you Level %d Admin!", PlayerName(playerid), level);
    SendClientMessage(target, COLOR_LIGHTGREEN, string);
    foreach(new i : Player)  // <--- error here
    {
        if(PlayerInfo[i][pAdmin] >= 4)
        {
            format(string, sizeof(string), "Admin %s has given %s level %d Admin!", PlayerName(playerid), PlayerName(target), level);
            SendClientMessage(i, COLOR_LIGHTRED, string);
        }
    }
    return 1;
}
dcmd_setmoney(playerid, params[]) // Level 3
{
    if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
    new target, amount;
    new string[128];
    if(sscanf(params, "ud", target, amount)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /setmoney [playerid/name] [amount]");
    if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid player id!");
    PlayerInfo[target][pMoney] = amount;
    ResetPlayerMoney(target);
    new newmoney = PlayerInfo[target][pMoney];
    GivePlayerMoney(target, newmoney);
    format(string, sizeof(string), "Admin %s has set your money to %d !", PlayerName(playerid), newmoney);
    SendClientMessage(target, COLOR_LIGHTGREEN, string);
    foreach(new i : Player)
    {
        if (PlayerInfo[i][pAdmin] >= 1)
        {
            format(string, sizeof(string), "Admin %s has set %s's money to %d !", PlayerName(playerid), PlayerName(target), amount);
            SendClientMessage(i, COLOR_LIGHTRED, string);
        }
    }
    return 1;
}

dcmd_givemoney(playerid, params[]) // Level 3
{
    if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
    new target, money;
    new string[128];
    if(sscanf(params, "ud", target, money)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /givemoney [playerid/name] [amount]");
    if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid player id!");
    if(money < 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You can't givemoney below 0!");
    GivePlayerMoney(target, money);
    PlayerInfo[target][pMoney] += money;
    format(string, sizeof(string), "Admin %s has given you %d !", PlayerName(playerid), money);
    SendClientMessage(target, COLOR_LIGHTGREEN, string);
    foreach(new i : Player)
    {
        if(PlayerInfo[i][pAdmin] >=1)
        {
            format(string, sizeof(string), "Admin %s has given %s %d !", PlayerName(playerid), PlayerName(target), money);
            SendClientMessage(i, COLOR_LIGHTRED, string);
        }
    }
    return 1;
}
dcmd_kick(playerid, params[]) // Level 1
{
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
    new user, reason[128], string[128];
    if(sscanf(params, "us[128]", user, reason)) return SendClientMessage(playerid, COLOR_ORANGE, "CMD: /kick [playerid/name] [reason]");
    if(!IsPlayerConnected(user)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid player id!");
    if(PlayerInfo[user][pAdmin] > PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid, COLOR_LIGHTRED, "You can't kick higher level Admins!");
    format(reason, sizeof(reason), "%s", reason);
    format(string, sizeof(string), "Admin %s has kicked %s, reason: %s", PlayerName(playerid), PlayerName(user), reason);
    SendClientMessageToAll(COLOR_LIGHTRED, string);
    Kick(user);
    return 1;
}

dcmd_veh(playerid, params[]) // Level 3
{
    if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_LIGHTRED, "You are not authorized to use this command!");
    if( !strlen( params ) ) return SendClientMessage(playerid, COLOR_LIGHTRED, "/veh [name] or [modelid]");
    new car = ReturnVehicleModelID(params);
    if(!car) return SendClientMessage(playerid, COLOR_LIGHTRED, "Invalid vehicle model id!");
    new Float:x,Float:y,Float:z,Float:a;
    GetPlayerPos(playerid, x,y,z);
    GetPlayerFacingAngle(playerid, a);
    CreateVehicle(car, x+1, y+1, z, a, -1, -1, 500);
    SendClientMessage(playerid, COLOR_LIGHTGREEN, "You've spawned a vehicle!");
    return 1;
}
About the line 1141, I assume you used return and after that you have code. Remove that return from there.
Still not working buddy!I have latest version and still

Код:
C:\Users\Dennis Laptop\Desktop\latw.pwn(1450) : error 017: undefined symbol "foreach"
C:\Users\Dennis Laptop\Desktop\latw.pwn(1450) : error 029: invalid expression, assumed zero
C:\Users\Dennis Laptop\Desktop\latw.pwn(1450) : error 029: invalid expression, assumed zero
C:\Users\Dennis Laptop\Desktop\latw.pwn(1450) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
HELP and i rep++
Reply
#4

The error says that foreach is undefined; however if you include foreach:
pawn Код:
// At the top:
#include <a_samp>
#include <foreach>
It's not then an undefined symbol. Try re-check it.
Reply
#5

Ok i deleted this admin system and now no errors i will get a new one which will be better cause this one sucked...really.....Anyway +Rep for help and remember i am Greek to!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)