Jump to content
  • 0

Acces vehicul Job


Rayan

Question

Salut, am incercat sa fac comanda /work insa nu stiu cum pot face ca masina de la job care i-a creat-o cand a folosit /work adica JobVehicle[playerid] sa o poata folosi doar el, atunci cand alt jucator da F/ENTER la masina respectiva sa ii apare ca e incuiata, doar jucatorul proprietar al masini de la job sa aiba acces de F/ENTE in ea, ma puteti ajuta? 

Comanda este aceasta:

CMD:work(playerid, params[])
{
	if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to log in first.");
	if(PlayerInfo[playerid][pCarLic] == 0) return SendClientMessage(playerid, COLOR_GREY, "You don't have driving licence.");
	if(JobWorking[playerid] == 1) return SendClientMessage(playerid, COLOR_GREY, "You already working. Use /stopwork if you don't want to work anymore.");
	if(IsPlayerConnected(playerid))
	{
		if(!AdminDuty[playerid]) {
			if(PlayerInfo[playerid][pJob] == 5) {
				if(IsPlayerInRangeOfPoint(playerid, 4, Job[5][X], Job[5][Y], Job[5][Z])) {
		            if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) {
		                JobVehicle[playerid] = CreateVehicle(448, Pos[0], Pos[1], Pos[2], 90.0000, -1, -1, -1);
		                PutPlayerInVehicleEx(playerid, JobVehicle[playerid], 0);
		                Gas[JobVehicle[playerid]] = 100;
		                JobWorking[playerid] = 1;
					}
					else return SCM(playerid, -1, "Nu poti folosi comanda intr-un vehicul.");
				}
			}
		}
	}
	return 1;
}

 

Link to comment
Share on other sites

17 answers to this question

Recommended Posts

  • 0
Acum 18 minute, WopsS a spus:

Salut,

Folosește SetVehicleParamsEx să blochezi vehiculul pentru toata lumea și folosește SetVehicleParamsForPlayer să îl deblochezi pentru jucătorul care o folosește.

Am incercat

SetVehicleParamsEx(JobVehicle[playerid],engine,lights,alarm,1,bonnet,boot,objective);

sa pun la comanda /work sub PutPlayerInVehicle

si la OnVehicleStreamIn am pus ceva de genu:

for(new vv; vv < MAX_VEHICLES; vv++)
    {
        if(vv == JobVehicle[forplayerid])
        {
            SetVehicleParamsForPlayer(vv,forplayerid,0,0);
        }
    }

Si cand ma dau jos din vehicul si apas F e incuiata.

Am incercat sa incerc si la OnPlayerEnterVehicle si nu merge, la fel..

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(!ispassenger)
    {
        if(vehicleid == JobVehicle[playerid])
        {
            SetVehicleParamsForPlayer(vehicleid,playerid,0,0);
        }
    }
    return 1;
}

Link to comment
Share on other sites

  • 0
Acum 5 minute, WopsS a spus:

Poți s-o pui în comanda /work. La OnVehicleStreamIn poți s-o faci mai simplu


if (vehicleid == JobVehicle[forplayerid])
{
	SetVehicleParamsForPlayer(vehicleid, forplayerid, 0, 0);
}

 

Am facut cum ai spus tu, insa nu functioneaza, ramane lock, nu se descuie...

Link to comment
Share on other sites

  • 0
Acum 9 minute, WopsS a spus:

Făi un debug la OnVehicleStreamIn.


printf("%i | %i", vehicleid, JobVehicle[forplayerid]);

 

 

----------
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3.7-R2, (C)2005-2015 SA-MP Team

[19:06:12] filterscripts = ""  (string)
[19:06:12] 
[19:06:12] Server Plugins
[19:06:12] --------------
[19:06:12]  Loading plugin: Whirlpool
[19:06:12]  
[19:06:12]  ==================
[19:06:12]  
[19:06:12]   Whirlpool loaded
[19:06:12]  
[19:06:12]  ==================
[19:06:12]  
[19:06:12]   Loaded.
[19:06:12]  Loading plugin: mysql.dll
[19:06:12]  >> plugin.mysql: R39-6 successfully loaded.
[19:06:12]   Loaded.
[19:06:12]  Loading plugin: sscanf.dll
[19:06:12] 

[19:06:12]  ===============================

[19:06:12]       sscanf plugin loaded.     

[19:06:12]          Version:  2.8.1        

[19:06:12]    (c) 2012 Alex "Y_Less" Cole  

[19:06:12]  ===============================

[19:06:12]   Loaded.
[19:06:12]  Loading plugin: crashdetect.dll
[19:06:12]   CrashDetect v4.15.1 is OK.
[19:06:12]   Loaded.
[19:06:12]  Loading plugin: streamer.dll
[19:06:12] 

*** Streamer Plugin v2.8.1 by Incognito loaded ***

[19:06:12]   Loaded.
[19:06:12]  Loaded 5 plugins.

[19:06:12] 
[19:06:13] Ban list
[19:06:13] --------
[19:06:13]  Loaded: samp.ban
[19:06:13] 
[19:06:13] 
[19:06:13] Filterscripts
[19:06:13] ---------------
[19:06:13]   Loaded 0 filterscripts.

[19:06:13]  
[19:06:13]  
[19:06:13]  
[19:06:13]  ======================================= 
[19:06:13]  |                                     | 
[19:06:13]  |        YSI version 4.00.0001        | 
[19:06:13]  |        By Alex "Y_Less" Cole        | 
[19:06:13]  |                                     | 
[19:06:13]  ======================================= 
[19:06:13]  
[19:06:13] ---------- SERVER START ----------
[19:06:13] [debug] OnGameModeInit()
[19:06:13] mysql_connect: 1
[19:06:13] ----------------------------------------------------
[19:06:13] Script: ExGaming Roleplay - Based on Saints Roleplay
[19:06:13] Status: Loaded, running version Zombie mode
[19:06:13] ----------------------------------------------------
[19:06:13] Number of vehicle models: 0
[19:06:13] [LOADING] 14 groups loaded.
[19:06:13] [LOADING] 438 vehicles loaded.
[19:06:13] [LOADING] 106 houses loaded.
[19:06:13] [LOADING] 48 turfs loaded.
[19:06:13] [LOADING] 54 businesses loaded.
[19:06:13] [LOADING] 105 models loaded.
[19:06:13] [LOADING] 0 clans loaded.
[19:06:13] [LOADING] 2 sVars loaded.
[19:06:13] Players registered: 3
[19:06:25] [connection] 127.0.0.1:52775 requests connection cookie.
[19:06:26] [connection] incoming connection: 127.0.0.1:52775 id: 0
[19:06:26] [join] RedGun has joined the server (0:127.0.0.1)
[19:06:31] RedGun has been connected to the server (IP: 127.0.0.1).
[19:06:36] 439 | 439 //aici e

 

Edited by Rayan
Link to comment
Share on other sites

  • 0
Acum 10 minute, WopsS a spus:

Asta înseamnă că nu poți să le folosești pe amândouă. Folosește doar SetVehicleParamsForPlayer, blochează vehiculul pentru toți jucătorii în afară de cel care muncește.

Am incercat,

foreach(new i : Player)
                        {
                            if(i != playerid) SetVehicleParamsEx(JobVehicle[playerid],engine,lights,alarm,1,bonnet,boot,objective);
                        }

Insa problema e ca cauta jucatori in momentul acela, daca un jucator nou se conecteaza, lui nu ii se incuie masina pentru masina de job la playerid

Link to comment
Share on other sites

  • 0
Acum 1 oră, WopsS a spus:

Atunci pune la OnPlayerConnect aceeasi chestie.

Am incercat, acum numai pune unlock la usile de la vehicul deloc, raman deschise...wtf

Am pus asa in comanda /work

 foreach(new x : Player) {
                            if(x != playerid) SetVehicleParamsForPlayer(pJobVehicle[playerid], x, 0, 1);
                        }
                        SetVehicleParamsForPlayer(pJobVehicle[playerid],playerid, 0, 0);

si in onplayerconnect

 foreach(new ids : Player) {
                            if(ids != playerid) SetVehicleParamsForPlayer(pJobVehicle[ids], playerid, 0, 1);
                        }
Edited by Rayan
Link to comment
Share on other sites

  • 0
9 minutes ago, Rayan said:

Am incercat, acum numai pune unlock la usile de la vehicul deloc, raman deschise...wtf

Am pus asa in comanda /work


 foreach(new x : Player) {
                            if(x != playerid) SetVehicleParamsForPlayer(pJobVehicle[playerid], x, 0, 1);
                        }
                        SetVehicleParamsForPlayer(pJobVehicle[playerid],playerid, 0, 0);

si in onplayerconnect


 foreach(new ids : Player) {
                            if(ids != playerid) SetVehicleParamsForPlayer(pJobVehicle[ids], playerid, 0, 1);
                        }

Daca am inteles corect, tu vrei ca atunci cand x tasteaza /work, sa il spawneze in  masina, iar apoi masina sa se blocheze.

Incearca asa:

CMD:work(playerid, params[])
{
	if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to log in first.");
	if(PlayerInfo[playerid][pCarLic] == 0) return SendClientMessage(playerid, COLOR_GREY, "You don't have driving licence.");
	if(JobWorking[playerid] == 1) return SendClientMessage(playerid, COLOR_GREY, "You already working. Use /stopwork if you don't want to work anymore.");
	if(IsPlayerConnected(playerid))
	{
		if(!AdminDuty[playerid]) {
			if(PlayerInfo[playerid][pJob] == 5) {
				if(IsPlayerInRangeOfPoint(playerid, 4, Job[5][X], Job[5][Y], Job[5][Z])) {
		            if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) {
		                JobVehicle[playerid] = CreateVehicle(448, Pos[0], Pos[1], Pos[2], 90.0000, -1, -1, -1);
		                PutPlayerInVehicleEx(playerid, JobVehicle[playerid], 0);
		                Gas[JobVehicle[playerid]] = 100;
		                JobWorking[playerid] = 1;
		                new engine, lights, alarm, doors, bonnet, boot, objective;
						GetVehicleParamsEx(JobVehicle[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
						SetVehicleParamsForPlayer(JobVehicle[playerid], playerid, 1, 0);
					}
					else return SCM(playerid, -1, "Nu poti folosi comanda intr-un vehicul.");
				}
			}
		}
	}
	return 1;
}

 

  • Like 1

**********************************

Servicii Scripting de calitate:

*********************************

Future Project: ExpertGame

*********************************

Link to comment
Share on other sites

  • 0
12 minutes ago, Rayan said:

@Daedric-Fox am facut asta, insa am nevoie ca accesul la vehicul sa fie doar pentru jucatorul care munceste, pentru ceilalti masina sa fie incuiata.

Pai e simplu:

Cu SetVehicleParamsEx ai blocat usile vehiculului, iar cu SetVehicleParamsforPlayer le.ai deblocat doar pentru el.

CMD:work(playerid, params[])
{
	if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to log in first.");
	if(PlayerInfo[playerid][pCarLic] == 0) return SendClientMessage(playerid, COLOR_GREY, "You don't have driving licence.");
	if(JobWorking[playerid] == 1) return SendClientMessage(playerid, COLOR_GREY, "You already working. Use /stopwork if you don't want to work anymore.");
	if(IsPlayerConnected(playerid))
	{
		if(!AdminDuty[playerid]) {
			if(PlayerInfo[playerid][pJob] == 5) {
				if(IsPlayerInRangeOfPoint(playerid, 4, Job[5][X], Job[5][Y], Job[5][Z])) {
		            if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) {
		                JobVehicle[playerid] = CreateVehicle(448, Pos[0], Pos[1], Pos[2], 90.0000, -1, -1, -1);
		                PutPlayerInVehicleEx(playerid, JobVehicle[playerid], 0);
		                Gas[JobVehicle[playerid]] = 100;
		                JobWorking[playerid] = 1;
		                new engine, lights, alarm, doors, bonnet, boot, objective;
						GetVehicleParamsEx(JobVehicle[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(JobVehicle[playerid], engine, lights, alarm,1,bonnet,boot,objective);
						SetVehicleParamsForPlayer(JobVehicle[playerid], playerid, 1, 0);
					}
					else return SCM(playerid, -1, "Nu poti folosi comanda intr-un vehicul.");
				}
			}
		}
	}
	return 1;
}
  • Like 1

**********************************

Servicii Scripting de calitate:

*********************************

Future Project: ExpertGame

*********************************

Link to comment
Share on other sites

  • 0

Cauta public onplayerentervehicle 

 

Si adauga

for (new i;i <MAX _PLAYERS;I++)

{

If (vehicleid == JobVehicle )// si apoi iful de sus

{

If(vehicleid != JobVehicle [playerid]) TogglePlayerControllable(playerid,1);

}

}

incerci si vezi care iti merge

  • Like 1

 

    __  ____      __           
   /  |/  (_)____/ /____  _____
  / /|_/ / / ___/ __/ _ \/ ___/
 / /  / / (__  ) /_/  __/ /    
/_/  /_/_/____/\__/\___/_/     
SERVICII SCRIPTING DE CALITATE
Pagina     Scripting     pawn
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.