Command not work
#1

Command not working?

if(APlayerData[playerid][PlayerLevel] < 1 && APlayerData[playerid][PlayerHelper])
Reply
#2

What's the cmd, you must paste the code of the cmd, and the errors if you have got some.
Reply
#3

Код:
COMMAND:fix(playerid, params[])
{
	if (APlayerData[playerid][LoggedIn] == true)
	{
        if(APlayerData[playerid][PlayerLevel] < 1 && APlayerData[playerid][PlayerHelper])
	if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a vehicle!"); // Let the player know he's not inside a vehicle and let the server know that this was a valid command
	RepairVehicle(GetPlayerVehicleID(playerid));
	SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been successfully Fixed!");
	}
	return 1;
}
Reply
#4

pawn Код:
COMMAND:fix(playerid, params[])
{
    if (!APlayerData[playerid][LoggedIn] == true) return SendClientMessage(playerid,0xFFFFFFFF,"You are not logged in");
        if(APlayerData[playerid][PlayerLevel] !< 1 && APlayerData[playerid][PlayerHelper] != 1) return SendClientMessage(playerid,-1,"You have to be at least level 1 and a helper.");
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a vehicle!"); // Let the player know he's not inside a vehicle and let the server know that this was a valid command
    RepairVehicle(GetPlayerVehicleID(playerid));
    SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been successfully Fixed!");
    return 1;
}
Reply
#5

Код:
error 001: expected token: ")", but found "!"
error 029: invalid expression, assumed zero
warning 215: expression has no effect
error 001: expected token: ";", but found ")"
fatal error 107: too many error messages on one line

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


4 Errors.
Reply
#6

It will be easier if you tell me the line, i think i know whats the problem
pawn Код:
COMMAND:fix(playerid, params[])
{
    if (!APlayerData[playerid][LoggedIn] == true) return SendClientMessage(playerid,0xFFFFFFFF,"You are not logged in");
        if(APlayerData[playerid][PlayerLevel] > 0 && APlayerData[playerid][PlayerHelper] != 1) return SendClientMessage(playerid,-1,"You have to be at least level 1 and a helper.");
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a vehicle!"); // Let the player know he's not inside a vehicle and let the server know that this was a valid command
    RepairVehicle(GetPlayerVehicleID(playerid));
    SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been successfully Fixed!");
    return 1;
}
Reply
#7

Still not no admin.

if i not a admin or helper

i can do /fix but how i do for helpers and admins?
Reply
#8

Quote:
Originally Posted by Tanush123
Посмотреть сообщение
It will be easier if you tell me the line, i think i know whats the problem
pawn Код:
COMMAND:fix(playerid, params[])
{
    if (!APlayerData[playerid][LoggedIn] == true) return SendClientMessage(playerid,0xFFFFFFFF,"You are not logged in");
        if(APlayerData[playerid][PlayerLevel] > 0 && APlayerData[playerid][PlayerHelper] != 1) return SendClientMessage(playerid,-1,"You have to be at least level 1 and a helper.");
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a vehicle!"); // Let the player know he's not inside a vehicle and let the server know that this was a valid command
    RepairVehicle(GetPlayerVehicleID(playerid));
    SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been successfully Fixed!");
    return 1;
}
I can appreciate that you are trying to help, but do you have any idea what you are doing? I understand you have good intentions but you shouldn't post code if you don't have a good understanding of what you are doing.

I have restructured your code to make it more readable and fixed your errors. I have not tested this code as I don't have a compiler right now, but any minor errors are probably typos and should be easily fixed.

pawn Код:
COMMAND:fix(playerid, params[])
{
    if(APlayerData[playerid][LoggedIn] == true)
    {
        if(APlayerData[playerid][PlayerLevel] > 0 && APlayerData[playerid][PlayerHelper] > 0)
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                RepairVehicle(GetPlayerVehicleID(playerid));
                SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been successfully fixed!");
            }
            else
            {
                SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a vehicle!");
            }
        }
        else
        {
            SendClientMessage(playerid, 0xFFFFFFFF, "You must be level 1 and a helper.");
        }
    }
    else
    {
        SendClientMessage(playerid, 0xFFFFFFFF, "You must be logged in.");
    }
    return 1;
}
If you are interested in learning how to fix your mistakes, here is a simple explanation of the operators you are trying to use.
  • If you want to check if a player is level 1 or above, you would use >.
  • If you want to check if the player is logged in, you would use == true.
Don't try to over-complicate things. The best way to structure a code (in my opinion), is to first run through all of the criteria needed to actually execute the command. Then, once you have gotten through all of the met criteria, you can decide what happens when a certain criteria is not met. That is what I did when restructuring your code above. You should try to pick a pattern that will allow for the most readability in your scripts. Whether you choose to account for failed checks first and then the command's actual execution or visa versa, you should be consistent.
Reply
#9

still not working.
Reply
#10

Quote:
Originally Posted by DerickClark
Посмотреть сообщение
still not working.
Instead of posting "still not working," why don't you post something useful? If you don't tell me what happens when you use the command I can't help you any further.

The command I posted checks if the player is level 1+ PlayerLevel, level 1+ PlayerHelper, and is in a vehicle. If the command still works when you aren't a helper then your helper system is not functioning correctly. With the information you have provided I have created a perfectly functioning command.
Reply


Forum Jump:


Users browsing this thread: