SA-MP Forums Archive
This code doesn't work [HELP] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: This code doesn't work [HELP] (/showthread.php?tid=327680)



This code doesn't work [HELP] - Reklez - 22.03.2012

This code doesn't work, i even set my Job to 1 here is the pawn code

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vehicleid == 420 || vehicleid == 438)
    {
        if(pInfo[playerid][JobMember] > 1 || pInfo[playerid][JobLeader] > 1)
        {
            SendClientMessage(playerid, COLOR_GREY, "/duty to be on/off Job Duty!");
            return 1;
        } else {
            SendClientMessage(playerid, COLOR_GREY, "  You are not Taxi Driver!  ");
            RemovePlayerFromVehicle(playerid);
        }
    }
    return 1;
}



Re: This code doesn't work [HELP] - MP2 - 22.03.2012

OnPlayerEnterVehicle is called when you START to enter a vehicle. Use OnPlayerKeyStateChange. Also, the vehicle ID is NOT the modelid.


Re: This code doesn't work [HELP] - Reklez - 22.03.2012

i search on ****** 'SAMP vehicleid' but i find the same vehicleid can you tell me what is the vehicleid of:

Taxi
Cabble


Re: This code doesn't work [HELP] - MP2 - 22.03.2012

https://sampwiki.blast.hk/wiki/Category:Vehicle


Re: This code doesn't work [HELP] - GtasaPoliceModz - 22.03.2012

At top of script
Код:
new Taxi1;
Under Gamemodeint
Код:
Taxi1 = CreateVehicle(   * Car Cordinates *
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new vid = GetPlayerVehicleID(playerid);
        if(vid == Taxi1 && PInfo[playerid][JOB] != 1) // Change *Taxi* to Car Id and Pinfo into your playervariables
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid, COLOR_GREY, "This car belongs to Fort Carson News.");
        }
      return 1;
}
    }



Re: This code doesn't work [HELP] - Reklez - 22.03.2012

it still doesn't work


Re: This code doesn't work [HELP] - Reklez - 22.03.2012

idk but still doesn't work

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new vid = GetPlayerVehicleID(playerid);
    if(newstate == PLAYER_STATE_PASSENGER || newstate == PLAYER_STATE_DRIVER) return SetPlayerArmedWeapon(playerid, 0);
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(vid == Taxi || vid == Cabble && pInfo[playerid][JobMember] != 1 && pInfo[playerid][JobLeader] != 1)
        {
            SendClientMessage(playerid, COLOR_GREY, "  You are not Taxi Driver!  ");
            RemovePlayerFromVehicle(playerid);
            return 1;
        } else if(pInfo[playerid][JobMember] == 1 && pInfo[playerid][JobLeader] == 1)
        {
            SendClientMessage(playerid, COLOR_GREY, "/duty to be on/off Job Duty!");
        }
    }
    return 1;
}



Re: This code doesn't work [HELP] - MP2 - 22.03.2012

if(newstate == PLAYER_STATE_PASSENGER || newstate == PLAYER_STATE_DRIVER) return SetPlayerArmedWeapon(playerid, 0);

'RETURN' stops the code.


Re: This code doesn't work [HELP] - Reklez - 22.03.2012

nothing happens even i make this

pawn Код:
new vid = GetPlayerVehicleID(playerid);
    if(newstate == PLAYER_STATE_DRIVER && vid == Taxi || vid == Cabble)
    {
        if(pInfo[playerid][JobMember] != 1 && pInfo[playerid][JobLeader] != 1) {
            SendClientMessage(playerid, COLOR_GREY, "  You are not Taxi Driver!  ");
            RemovePlayerFromVehicle(playerid);
            return 1;
        } else if(pInfo[playerid][JobMember] == 1 && pInfo[playerid][JobLeader] == 1) {
            SendClientMessage(playerid, COLOR_GREY, "/duty to be on/off Job Duty!");
        }
    }
    if(newstate == PLAYER_STATE_PASSENGER || newstate == PLAYER_STATE_DRIVER)
    {
        SetPlayerArmedWeapon(playerid, 0);
        return 1;
    }



Re: This code doesn't work [HELP] - MP2 - 22.03.2012

Sigh.

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new vid = GetPlayerVehicleID(playerid);
    if(newstate == PLAYER_STATE_PASSENGER || newstate == PLAYER_STATE_DRIVER) SetPlayerArmedWeapon(playerid, 0);
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(GetVehicleModel(vid) == 420 || GetVehicleModel(vid) == 438) // Entered taxi
        {
            if(pInfo[playerid][JobMember] != 1 && pInfo[playerid][JobLeader] != 1)
            {
                SendClientMessage(playerid, COLOR_GREY, "  You are not a Taxi Driver!  ");
                RemovePlayerFromVehicle(playerid);
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "/duty to be on/off Job Duty!");
            }
        }
    }
    return 1;
}
Try that.