DCMD commands prob
#1

Hi,i've this commands in DCMD:

Код:
dcmd_g(playerid, params[])
{
	new id;
	if(sscanf(params, "u", id))
		return SendClientMessage(playerid, COLOR_RED, "SYNTAX: /goto [nick/id]");
	if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id))
	    return SendClientMessage(playerid, COLOR_RED, "ERROR: That player is not connected.");

	new Float:Pos[3];
	if(IsPlayerInAnyVehicle(playerid))
 	{
		GetPlayerPos(id, Pos[0], Pos[1], Pos[2]);
		SetVehiclePos(GetPlayerVehicleID(playerid), Pos[0]+2, Pos[1], Pos[2]);
		PutPlayerInVehicle(playerid, GetPlayerVehicleID(playerid), 0);
		SetPlayerInterior(playerid, GetPlayerInterior(id));
		SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(id));
	}
	else
	{
	 	GetPlayerPos(id, Pos[0], Pos[1], Pos[2]);
		SetPlayerPos(playerid, Pos[0]+1, Pos[1], Pos[2]);
		SetPlayerInterior(playerid, GetPlayerInterior(id));
		SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(id));
	}
	return 1;
}

dcmd_get(playerid, params[])
{
	new id;
 	if(sscanf(params, "u", id))
		return SendClientMessage(playerid, COLOR_RED, "SYNTAX: /gethere [nick/id]");
	if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id))
	    return SendClientMessage(playerid, COLOR_RED, "ERROR: That player is not connected.");

	new Float:Pos[3];
    if(IsPlayerInAnyVehicle(id))
    {
		GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
		SetVehiclePos(GetPlayerVehicleID(id), Pos[0]+2, Pos[1], Pos[2]);
		PutPlayerInVehicle(id, GetPlayerVehicleID(id), 0);
		SetPlayerInterior(playerid, GetPlayerInterior(id));
		SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(id));
	}
	else
	{
        GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
		SetPlayerPos(id, Pos[0]+1, Pos[1], Pos[2]);
		SetPlayerInterior(playerid, GetPlayerInterior(id));
		SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(id));
	}
	return 1;
}

dcmd_explode(playerid, params[])
{
	new id,toplayerid;
	if(sscanf(params, "u", id))
	    return SendClientMessage(playerid, COLOR_RED, "SYNTAX: /explode [nick/id]");
	if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id))
	    return SendClientMessage(playerid, COLOR_RED, "ERROR: That player is not connected!");
    new expString[128], adminName[24], exploName[24];
    GetPlayerName(playerid, adminName, 24);
    GetPlayerName(toplayerid, exploName, 24);
    format(expString, 128, "Player %s was exploded by Administrator %s.", exploName, adminName);
    SendClientMessageToAll(COLOR_RED, expString);
    new str[100];
    format(str,sizeof str,"0,4Player %s was exploded by Administrator %s.", exploName, adminName);
   	IRC_GroupSay(gGroupID, IRC_CHANNEL, str);
	new Float:Pos[3];
	GetPlayerPos(id, Pos[0], Pos[1], Pos[2]);
	CreateExplosion(Pos[0], Pos[1], Pos[2], 0, 10.0);
	return 1;
}

dcmd_slap(playerid, params[])
{
    new id,toplayerid;
	if(sscanf(params, "u", id))
	    return SendClientMessage(playerid, COLOR_RED, "SYNTAX: /slap [nick/id]");
	if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id))
	    return SendClientMessage(playerid, COLOR_RED, "ERROR: That player is not connected!");

    new slString[128], adminName[24], slapName[24];
    GetPlayerName(playerid, adminName, 24);
    GetPlayerName(toplayerid, slapName, 24);
    format(slString, 128, "Player %s was slapped by Administrator %s.", slapName, adminName);
    SendClientMessageToAll(COLOR_RED, slString);
    new str[100];
    format(str,sizeof str,"0,4Player %s was slapped by Administrator %s.", slapName, adminName);
   	IRC_GroupSay(gGroupID, IRC_CHANNEL, str);
	new Float:Pos[3];
	GetPlayerPos(id, Pos[0], Pos[1], Pos[2]);
	SetPlayerPos(id, Pos[0], Pos[1], Pos[2]+7);
	return 1;
}
And i've a problem,the gm compiles fine,but if i add:

if(PlayerInfo[playerid][AdminLevel] > 2)
{

After

dcmd_EXAMPLECMD(playerid, params[])
{

I get tons of errors.

Код:
  if(PlayerInfo[playerid][AdminLevel] > 2)
Is the variable used for admin levels.

Any help?
Reply
#2

And you are sure that you closed the if statment again ?

And what kind of errors ?
Reply
#3

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
And you are sure that you closed the if statment again ?

And what kind of errors ?
Yes im sure.

Pawno returns me all sort of error (undefiened symbol,etc)..
Reply
#4

I assume you have all your commands in a separate include-file?

If you add that line in your commands-file, you have to make sure that PlayerInfo is declared before you include your commands-file, otherwise the compiler complains about PlayerInfo not being defined yet.
This would be logical, if PlayerInfo is declared below your included commands-file.

Код:
#include <PlayerCommands>

enum PInfo
{
// your fields here
}

new PlayerInfo[MAX_PLAYERS][PInfo];
this example would give lots of errors about such a mistake, as the compiler hasn't seen your declaration of PlayerInfo yet when including your commands-file.

Solution:
Код:
enum PInfo
{
// your fields here
}

new PlayerInfo[MAX_PLAYERS][PInfo];


#include <PlayerCommands>
Reply
#5

Umh,the PlayerInfo is declared under the Main()

Код:
main()
{
	print("\n----------------------------------");
	print("BLA BLA BLA");
	print("----------------------------------\n");
}

enum pInfo
{
     AdminLevel,
     Cash,
     Score,
     Deaths,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Reply
#6

BUMP
Reply
#7

Hey, thanks for leaving my credits on the commands... (yes, I am being sarcastic)
Reply
#8

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
Hey, thanks for leaving my credits on the commands... (yes, I am being sarcastic)
I havent removed credits.

I've removed the // just for posting the code here.
Reply
#9

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
Yes im sure.

Pawno returns me all sort of error (undefiened symbol,etc)..
i had the same problem because i used > and you have to use >=
try that and tell me
Reply
#10

Quote:
Originally Posted by matute
Посмотреть сообщение
i had the same problem because i used > and you have to use >=
try that and tell me
Actually, it has to be < considering the way I originally coded the commands for him.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)