[HowTo] Convert Public Enemy LS to 0.3 & PEN1 Questions
#1

[HowTo] Convert Public Enemy LS to 0.3
Feel free to post how to fix something
Hello!
Today I was downloaded Public Enemy LS - The Original, and when I was testing it, it worked fine. Then I had modified some things in gamemode, I was going to test it, but when I spawned I was in house. That is not usual because you shall spawn at motel in Los Santos, not house (actually, in trailer). I saw few guys need help to make it work, so heres a little guide. So now, I got a solution for it - saving system is saving

PLlayerInfo[playerid][plPhousekey] instead of PlayerInfo[playerid][pPhousekey] (also for business), i'm not sure why there is two enumerations with saving data, but OK.

As you maybe saw, under OnPlayerConnect there is
pawn Код:
PlayerInfo[playerid][pPhousekey] = 255;
PlayerInfo[playerid][pPbiskey] = 255;
and PLlayerInfo[playerid][plPhousekey] is not initialized and its value is still zero (which is trailer house's ID).

So, this is how it works on not-modified PENLS

You connect to server, register, your current Phousekey value is 255 (not house) because it is initialized under OnPlayerConnect, but when you disconnect it saves plPhousekey which is zero (trailer house's ID), and next time you connect, it spawns you at that trailer.

What you need to do is to add PLlayerInfo[playerid][plPhousekey] and PLlayerInfo[playerid][plPbiskey] under OnPlayerConnect, so it should look like
pawn Код:
public OnPlayerConnect(playerid)
{
    ....
    PLlayerInfo[playerid][plPhousekey] = 255;
    PLlayerInfo[playerid][plPbiskey] = 255;
    PlayerInfo[playerid][pPhousekey] = 255;
    PlayerInfo[playerid][pPbiskey] = 255;
    ....
    return 1;
}
That's it!

Next step you have to do is to replace OnPlayerUpdate to some other name, lets say OnUpdatePlayer (its not related to houses and business).
You can do it by pressing CTRL+H. In first textbox type OnPlayerUpdate and in second one OnUpdatePlayer.

Now do this
Quote:
Originally Posted by AndryXoX
Add This (by me)

Код:
public OnPlayerSpawn(playerid)
{
	if (gdebug >=1){printf("OnPlayerSpawn Playerid:%d", playerid);}
	new playername[40];
	if (teamcarlock)
	{
		TeamLockDoors(playerid);
	}
	InitLockDoors(playerid);
	if(accountplay)
	{
		if (gdebug >=1){printf("accountplay");}
		if (gPlayerAccount[playerid] == 0)
		{
			gTeam[playerid] = 0;
			GameTextForPlayer(playerid, "~w~Welcome.~n~In order to play you need to create an account, type ~n~~r~/regnick (password)~w~ to register", 20000, 3);
			//SetPlayerInterior(playerid,0);
			SetPlayerInterior(playerid,3);
			PlayerInfo[playerid][pInt] = 3;
			SetPlayerPos(playerid,198.5,162.5,1003.0);
			// airport
			PlayJailSound(1153 , 1154, 2000,264.395200, 77.564040, 1001.039000);
			gPlayerSpawned[playerid] = 1;
  		return 1;
		}
		if (gPlayerLogged[playerid] == 0)
		{
			gTeam[playerid] = 0;
			GameTextForPlayer(playerid, "~w~In order to play you need to log in to your account, type ~n~~g~/login (password)~w~ to log in", 20000, 3);
			//SetPlayerInterior(playerid,0);
			SetPlayerInterior(playerid,3);
			PlayerInfo[playerid][pInt] = 3;
			SetPlayerPos(playerid,198.5,162.5,1003.0);
			// airport
			PlayJailSound(1153 , 1154, 2000,264.395200, 77.564040, 1001.039000);
			gPlayerSpawned[playerid] = 1;
  		return 1;
		}
	}
if (gPlayerSpawned[playerid] == 1)
	{
		gTeam[playerid] = PlayerInfo[playerid][pTeam];
		if (gTeam[playerid] == 2 && forceteam && CopCheck(playerid))
		{
			gTeam[playerid] = 3;
			PlayerInfo[playerid][pTeam] = 3;
			SetPlayerRandomSpawn(playerid);
			SendClientMessage(playerid, COLOR_YELLOW, "SERVER: Your are not allowed to be a cop.");
		}
Edit if (gPlayerSpawned[playerid] == 1) Change 0 to 1
Now follow those instructions (all credits to AndryXoX)
Quote:
Originally Posted by AndryXoX
To correct the mission HotWire (checkpoints)
replace and/or add
pawn Код:
SetVehicleParamsForPlayer(stealcar,i,1,0);
SetPlayerCheckpoint(i,scx, scy, scz,5.0 );
1- On public OnPlayerSpawn(playerid)

Remove first /* switch (MissionActive) }/*
On the line case 9://Car is waiting first occupent
pawn Код:
{
                if (gTeam[playerid] == 1)
                {
                    SendClientMessage(playerid, COLOR_YELLOW, objstore);
                    SetVehicleParamsForPlayer(stealcar,playerid,1,0);
                        SetPlayerCheckpoint(playerid,scx, scy, scz,5.0 );
                }
                else if (gTeam[playerid] == 2)
                {
                SendClientMessage(playerid, TEAM_BLUE_COLOR, cbjstore);
                SetVehicleParamsForPlayer(stealcar,playerid,1,1);
                    SetPlayerCheckpoint(playerid,scx, scy, scz,5.0 );
                }
            }
2- On public PrePlayerNewMission()

pawn Код:
if (MissionActive > 8 && MissionActive < 12)
    {
        if(MissionActive != 0)
        {
            printf("DEBUG: Bad Hotwire: stealcar = %d, stealcardest = %d",stealcar,stealcardest);
            for(new i = 0; i <= MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i))
                {
                    if(stealcar != -1)
                    {
                    SetVehicleParamsForPlayer(stealcar,i,0,0);
                            SetPlayerCheckpoint(i,scx, scy, scz,5.0 );
                        SetVehicleToRespawn(stealcar);
                        stealcar = -1;
                    }
3- Under public SetPlayerNewMission()

On the line case 8:
pawn Код:
{
            if (gdebug){print("DEBUG test1");}
            stealcar = random(166)+88;
            GetVehiclePos(stealcar, scx, scy, scz);
            format(objstore, sizeof(objstore), "SMS: A Buyer Is Interested In The Car Marked On Your GPS, Sender: MOLE (555)");
            format(cbjstore, sizeof(cbjstore), "HQ: 911 10-64 Suspect Vehicle Spotted.");
            rx = scx;//storing the car pos
            ry = scy;
            rz = scz;
            if (gdebug){print("DEBUG TEST2");}
            stealcardest = random(166)+88;
            while (stealcardest == stealcar)
            {
                stealcardest = random(166)+88;
            }
            MissionActive = 9;
            if (gdebug){print("DEBUG MissionActive = 9;");}
            for(new i = 0; i <= MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i) && (gPlayerSpawned[i] == 1))
                {
                    if (gdebug){print("DEBUG test2");}
                    if (gTeam[i] >= 3)
                    {
                        if (automission)
                        {
                            JobGive(i);
                        }
                        else if (PlayerInfo[i][pPnumber] !=0)
                        {
                            SendClientMessage(i, COLOR_YELLOW, "SMS: I Got A Job For You, Text Yes To 555 For More Info, Sender: MOLE (555)");
                            SendClientMessage(i, COLOR_WHITE, "HINT: Type (/sms 555 yes) to get the waypoint from mole");
                            RingTone[i] =20;
                        }
                    }
                    else
                    {
                        if (gdebug){print("DEBUG test4");}
                        SendClientMessage(i, COLOR_DBLUE, cbjstore);
                        GameTextForPlayer(i, "~w~Waypoint set ~n~~y~Suspect Vehicle", 5000, 1);
                        SetPlayerCheckpoint(i,scx, scy, scz,5.0 );
                        SetVehicleParamsForPlayer(stealcar,i,1,1);

                    }
                }
            }
            if (gdebug){printf("DEBUG HOTWIRE mission started: TargetCar:%d",stealcar);}
        return 1;
        }
On the line case 10:
pawn Код:
{
            for(new i = 0; i <= MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i))
                {
                    if (!IsPlayerInVehicle(i, stealcar))
                    {
    SetPlayerCheckpoint(i,scx, scy, scz,5.0 );[/color]
                        SetVehicleParamsForPlayer(stealcar,i,1,0);
                    }
                }
            }
            return 1;
        }
On the line case 101:
pawn Код:
{
            for(new i = 0; i <= MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i))
                {
                    if (!IsPlayerInVehicle(i, stealcar))
                    {
                        SetPlayerCheckpoint(i,scx, scy, scz,5.0 );
                        SetVehicleParamsForPlayer(stealcar,i,1,0);
                    }
                    //SetAllPlayerCheckpoint(scx, scy, scz, 16.0, 255);
                }
            }
            return 1;
        }
4- On public JobGive(playerid)

On the line (MissionActive == 9)
pawn Код:
{
        SendClientMessage(playerid, COLOR_YELLOW, objstore);
        RingTone[playerid] = 20;
        SetVehicleParamsForPlayer(stealcar,playerid,1,0);
            SetPlayerCheckpoint(playerid,scx, scy, scz,5.0 );
        SendClientMessage(playerid, COLOR_WHITE, "HINT: Go To The Yellow Marker And Steal The Car.");
        GameTextForPlayer(playerid, "~w~Nuova Missione ~n~~y~Ruba il Veicolo", 5000, 1);
        return 1;
    }
5- On public LockCar(carid)
pawn Код:
{
    if (gdebug >= 1){printf("DEBUG LockCar(%d)",carid);}
    for(new i = 0; i <= MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(stealcar == carid)
            {
                SetVehicleParamsForPlayer(carid,i,1,1);
                    SetPlayerCheckpoint(i,scx, scy, scz,5.0 );
            }
            else
            {
                SetVehicleParamsForPlayer(carid,i,0,1);
                    SetPlayerCheckpoint(i,scx, scy, scz,5.0 );
            }
        }
    }
}
On public OnPlayerExitVehicle(playerid, vehicleid)
pawn Код:
{
    if (gdebug >= 1){printf("DEBUG OnPlayerExitVehicle(%d, %d)", playerid, vehicleid);}
    if (GetPlayerState(playerid) == 1)
    {
        return 1;
    }
    new string[256];
    new ename[MAX_PLAYER_NAME];
    if (vehicleid == stealcar && (MissionActive == 10 || MissionActive == 101))
    {
        GameTextForPlayer(playerid, "~w~Torna indietro e prendi la ~n~~r~Macchina!", 5000, 1);
        for(new i = 0; i <= MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
            SetVehicleParamsForPlayer(stealcar,i,1,0);
                    SetPlayerCheckpoint(i,scx, scy, scz,5.0 );
            }
        }
Under public OnPlayerStateChange(playerid, newstate, oldstate)
pawn Код:
if(gTeamCarLock[newcar] == 1)
        {
            gTeamCarLock[newcar] = 0;
            UnLockCar(newcar);
        }
        gLastCar[playerid] = newcar;
        if (gdebug >=1){printf("gLastCar[playerid](%d)",gLastCar[playerid]);}
        gLastDriver[newcar] = playerid;
        if ((newcar == stealcar) && (MissionActive == 9))
        {
            RewardCalc(playerid,1000,10000);
        }
        if((newcar == stealcar) && (MissionActive >= 9))
        {
            if (gdebug){print("DEBUG TEST3");}
            if (gTeam[playerid] >= 3 && MissionActive >= 9)
            {
                if (gdebug){print("DEBUG TEST4");}
                new name[MAX_PLAYER_NAME];
                new string[256];
                GetPlayerName(playerid, name, sizeof(name));
                GetVehiclePos(stealcardest, cwx, cwy, cwz);
                GameTextForPlayer(playerid, "~w~NOra porta la ~y~Macchina~n~~w~all' ~r~Acquirente", 5000, 1);
                format(string, sizeof(string), "%s Ha rubato una macchina contenente $%d", name,reward);
                BroadCast(COLOR_YELLOW, string);
                SetAllPlayerCheckpoint(cwx, cwy, cwz, 16.0, 0);
                gPlayerCheckpointStatus[playerid] = CHECKPOINT_CARDROP;
                MissionActive = 10;
                if (gdebug){print("DEBUG MissionActive = 10;");}
                if (gTeam[playerid] == 3)
                {
                    SetPlayerCriminal(playerid,255, "Grand Theft Auto",0,0);
                }
                gSuperCop = playerid;
                OpenDoors();
            }
ADD THIS
pawn Код:
if (gTeam[playerid] == 2 && MissionActive >= 9)
            {
                if (gdebug){print("DEBUG TEST6");}
                GameTextForPlayer(playerid, "~w~You are Cop, please Wait other gangs or civilian", 5000, 1);
        RemovePlayerFromVehicle(playerid);
                if (gdebug){print("DEBUG MissionActive = 10;");}
            }
pawn Код:
if (gTeam[playerid] == 2 && MissionActive >= 10)
            {
                if (gdebug){print("DEBUG TEST6");}
                new name[MAX_PLAYER_NAME];
                new string[256];
                GetPlayerName(playerid, name, sizeof(name));
                cwx = 1539.1;
                cwy = -1668.0;
                cwz = 5.8;
                GameTextForPlayer(playerid, "~w~Riporta la ~y~Macchina ~n~~w~al ~r~Punto di incontro", 5000, 1);
                format(string, sizeof(string), "Officer %s Has Seized A Stolen Car Worth $%d", name,reward);
                BroadCast(COLOR_YELLOW, string);
                SetAllPlayerCheckpoint(cwx, cwy, cwz, 16.0, 0);
                gPlayerCheckpointStatus[playerid] = CHECKPOINT_CARDROP;
                gSuperCop = playerid;
                MissionActive = 10;
                if (gdebug){print("DEBUG MissionActive = 10;");}
            }
        }
    }
    if(newstate == PLAYER_STATE_SPAWNED)
Quote:
Originally Posted by juuleman
Посмотреть сообщение
Please add to the main post:

Add this to your script:

pawn Код:
public OnVehicleStreamIn(vehicleid, forplayerid)
{
   if(gCarLock[vehicleid] == 1)
   {
       SetVehicleParamsForPlayer(vehicleid, forplayerid, 0, 1);
   }
   return 1;
}
This will fix the /lock bug. Now the cars stay locked fine.
That should be it! Your PENLS should work fine now on SA-MP 0.3 servers.


Original topic: http://forum.sa-mp.com/index.php?topic=40910.0
Reply


Messages In This Thread
[HowTo] Convert Public Enemy LS to 0.3 & PEN1 Questions - by Luka P. - 05.03.2010, 20:09
Re: [HowTo] Convert Public Enemy LS to 0.3 - by arcangel - 05.03.2010, 22:41
Re: [HowTo] Convert Public Enemy LS to 0.3 - by Luka P. - 05.03.2010, 22:58
Re: [HowTo] Convert Public Enemy LS to 0.3 - by arcangel - 05.03.2010, 23:54
Re: [HowTo] Convert Public Enemy LS to 0.3 - by nik29 - 06.03.2010, 06:39
Re: [HowTo] Convert Public Enemy LS to 0.3 - by WackoX - 06.03.2010, 09:36
Re: [HowTo] Convert Public Enemy LS to 0.3 - by Luka P. - 06.03.2010, 10:49
Re: [HowTo] Convert Public Enemy LS to 0.3 - by arcangel - 06.03.2010, 13:51
Re: [HowTo] Convert Public Enemy LS to 0.3 - by ArTisT - 06.03.2010, 15:16
Re: [HowTo] Convert Public Enemy LS to 0.3 - by AndryXoX - 06.03.2010, 15:51

Forum Jump:


Users browsing this thread: 2 Guest(s)