Help Me With RemovePlayerFormVehicle rep+
#1

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  new vehid = vehicleid;
  if(vehid == 425 )//hunter
   {
    if(GetPlayerScore(playerid) < 1500) return BisasaJe(playerid,"You Must Be A General To Drive This Vehicle !");
   }
   if(vehid == 520 )//Hydra
   {
    if(GetPlayerScore(playerid) < 1000) return BisasaJe(playerid,"You Must Be A Major To Drive This Vehicle !");
   }
    if(vehid == 432 )//Rhino
   {
    if(GetPlayerScore(playerid) < 800) return BisasaJe(playerid,"You Must Be A Pilot To Drive This Vehicle !");
   }
   if(vehid == 447 )//Seasparrow
   {
    if(GetPlayerScore(playerid) < 500) return BisasaJe(playerid,"You Must Be A Sergeant To Drive This Vehicle !");
   }
   if(vehid == 476 )//Rustler
   {
    if(GetPlayerScore(playerid) < 200) return BisasaJe(playerid,"You Must Be A Corporal To Drive This Vehicle !");
   }
  return 1;
}


stock BisasaJe(playerid,text[])
{
 RemovePlayerFromVehicle(playerid);
 new Float:x,Float:y,Float:z;
 GetPlayerPos(playerid,x,y,z);
 SendClientMessage(playerid,-1,text);
 return 1;
}
i have 0 score, after i get in Rhino,Hydra,Seasparrow, nothing working !!! Message also not showed , please help

rep +;
Reply
#2

You need to use
pawn Код:
new vehid = GetVehicleModel(vehicleid);
Reply
#3

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new vehid = GetVehicleModel(GetPlayerVehicleID(playerid));
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(vehid == 425 )//hunter
        {
            if(GetPlayerScore(playerid) < 1500) return BisasaJe(playerid,"You Must Be A General To Drive This Vehicle !");
        }
        if(vehid == 520 )//Hydra
        {
            if(GetPlayerScore(playerid) < 1000) return BisasaJe(playerid,"You Must Be A Major To Drive This Vehicle !");
        }
        if(vehid == 432 )//Rhino
        {
            if(GetPlayerScore(playerid) < 800) return BisasaJe(playerid,"You Must Be A Pilot To Drive This Vehicle !");
        }
        if(vehid == 447 )//Seasparrow
        {
            if(GetPlayerScore(playerid) < 500) return BisasaJe(playerid,"You Must Be A Sergeant To Drive This Vehicle !");
        }
        if(vehid == 476 )//Rustler
        {
            if(GetPlayerScore(playerid) < 200) return BisasaJe(playerid,"You Must Be A Corporal To Drive This Vehicle !");
        }
    }
    return 1;
}


stock BisasaJe(playerid,text[])
{
    RemovePlayerFromVehicle(playerid);
    new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid,x,y,z);
    SendClientMessage(playerid,-1,text);
    return 1;
}
Reply
#4

Quote:
Originally Posted by xganyx
Посмотреть сообщение
pawn Код:
new vehid = GetPlayerVehicleID(playerid);
OnPlayerEnterVehicle callback gives you the vehicleid already. It's kind of pointless to re-get the exactly same vehicleid by using GetPlayerVehicleID. What he needs is to get the modelid and compare it, so the solution is what Dragonsaurus said!

Also using switch is faster:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new vehid = GetVehicleModel(vehicleid);
    switch(vehid)
    {
        case 425: if(GetPlayerScore(playerid) < 1500) BisasaJe(playerid,"You Must Be A General To Drive This Vehicle !");
        case 520: if(GetPlayerScore(playerid) < 1000) BisasaJe(playerid,"You Must Be A Major To Drive This Vehicle !");
        case 432: if(GetPlayerScore(playerid) < 800) BisasaJe(playerid,"You Must Be A Pilot To Drive This Vehicle !");
        case 447: if(GetPlayerScore(playerid) < 500) BisasaJe(playerid,"You Must Be A Sergeant To Drive This Vehicle !");
        case 476: if(GetPlayerScore(playerid) < 200) BisasaJe(playerid,"You Must Be A Corporal To Drive This Vehicle !");
    }
    return 1;
}


stock BisasaJe(playerid,text[])
{
    RemovePlayerFromVehicle(playerid);
    new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid,x,y,z);
    SendClientMessage(playerid,-1,text);
}
PS: I don't get why do you get the player's position in BisasaJe if you do not use it anywhere?
Reply
#5

Quote:
Originally Posted by xganyx
Посмотреть сообщение
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new vehid = GetPlayerVehicleID(playerid);
@ Upper: He seems to use OnPlayerStateChange callback...
Reply
#6

So? It still should be:
pawn Код:
new
    vehid = GetVehicleModel( GetPlayerVehicleID( playerid ) )
;
What the author wants to compare is the modelid not the vehicleid..
Reply
#7

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
OnPlayerEnterVehicle callback gives you the vehicleid already
I got the main point of the poster, I already noticed xganyx's mistake, but that post was just to clear out something that could be just a little misunderstanding. I saw that he used OnPlayerStateChange, and took the vehicle's ID instead of the Model, and you mentioned OnPlayerEnterVehicle instead.
Reply
#8

Quote:
Originally Posted by Dragonsaurus
Посмотреть сообщение
I got the main point of the poster, I already noticed xganyx's mistake, but that post was just to clear out something that could be just a little misunderstanding. I saw that he used OnPlayerStateChange, and took the vehicle's ID instead of the Model, and you mentioned OnPlayerEnterVehicle instead.
Okay i fixed that and i'm WazzUp not xganyx anymore...
Reply
#9

that made a problem to me back then
that's mine
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    //Army Permissions
    if(GetVehicleModel(vehicleid) == 432 || GetVehicleModel(vehicleid) == 520 || GetVehicleModel(vehicleid) == 425)
    {  
     if(gTeam[playerid] != TEAM_ARMY)
         {
            SendClientMessage(playerid, COLOR_RED,"[ERROR] You must be an army officer in order to use this vehicle.");
            ClearAnimations(playerid,1);
            return 1;
         }
    }
return 1;
}
Reply
#10

Quote:
Originally Posted by Vanter
Посмотреть сообщение
that made a problem to me back then
that's mine
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    //Army Permissions
    if(GetVehicleModel(vehicleid) == 432 || GetVehicleModel(vehicleid) == 520 || GetVehicleModel(vehicleid) == 425)
    {  
     if(gTeam[playerid] != TEAM_ARMY)
         {
            SendClientMessage(playerid, COLOR_RED,"[ERROR] You must be an army officer in order to use this vehicle.");
            ClearAnimations(playerid,1);
            return 1;
         }
    }
return 1;
}
A tip. It's better to store the vehicle's model in a variable instead of calling GetVehicleModel many times. Or even a switch would work fine as well if there were more models to check.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)