Class Problem.
#1

I have Problem with My Class....
"I have Solider and Engineer Class"
and I want Both Class Can Drive Tanks.

pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
   new EngCheck = GetVehicleModel(GetPlayerVehicleID(playerid));
   if(EngCheck == 432)
   if (Solider[playerid] == 0 || Eng[playerid] == 0)
   {
     SendClientMessage(playerid, COLOR_RED, " You Need Solider/Engineer To Drive Tanks");  
     RemovePlayerFromVehicle(playerid);
   }
return 1;
}
But..when I'm Solider I Can't Drive Tank.
Message " You Need Solider/Engineer To Drive Tanks"

what's the problem?
Reply
#2

new bool:Solider[MAX_PLAYERS] = false;

^ what i would use

Anyway...Are their Solider and Eng set correctly, also;
pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
    {
        new EngCheck = GetVehicleModel(GetPlayerVehicleID(playerid));
        if(EngCheck == 432)
        {
            if(Solider[playerid] == 0 || Eng[playerid] == 0)
            {
                SendClientMessage(playerid, COLOR_RED, " You Need Solider/Engineer To Drive Tanks");  
                RemovePlayerFromVehicle(playerid);
            }
        }
    }
    return 1;
}
EDIT: here's what i mean by bool instead

pawn Код:
new bool:isSoldier[MAX_PLAYERS] = false,
    bool:isEng[MAX_PLAYERS] = false;
//Then you'd just isSoldier[playerid] = true; same with eng

public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
    {
        new EngCheck = GetVehicleModel(GetPlayerVehicleID(playerid));
        if(EngCheck == 432)
        {
            if(Soldier[playerid] == false || Eng[playerid] == false)
            {
                SendClientMessage(playerid, COLOR_RED, " You Need Solider/Engineer To Drive Tanks");  
                RemovePlayerFromVehicle(playerid);
            }
        }
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by [ABK]Antonio
Посмотреть сообщение
new bool:Solider[MAX_PLAYERS] = false;

^ what i would use

Anyway...Are their Solider and Eng set correctly, also;
pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
    {
        new EngCheck = GetVehicleModel(GetPlayerVehicleID(playerid));
        if(EngCheck == 432)
        {
            if(Solider[playerid] == 0 || Eng[playerid] == 0)
            {
                SendClientMessage(playerid, COLOR_RED, " You Need Solider/Engineer To Drive Tanks");  
                RemovePlayerFromVehicle(playerid);
            }
        }
    }
    return 1;
}
but if I'm (Solider or Engineer) that Message show again.
Reply
#4

Quote:
Originally Posted by V_LOPE
Посмотреть сообщение
but if I'm (Solider or Engineer) that Message show again.
Then the vars probably aren't set correctly for them...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)