Lock by Dissconect
#1

Hello i want when i locked my car and i go offline or die in my car, the doors automatic open

Here my script


Код:
if(!strcmp(cmdtext,"/lock"))
	{
	new Float:VX,Float:VY,Float:VZ;
	for(new vehicleid=1;vehicleid<MAX_VEHICLES;vehicleid++)
	{
	    GetVehiclePos(vehicleid,VX,VY,VZ);
	    if(!IsPlayerInRangeOfPoint(playerid,2.5,VX,VY,VZ))continue;
		if(Lock[vehicleid] == 0)
		{
		    Lock[vehicleid] = 1;
		    SendClientMessage(playerid,COLOR_GREEN," Car closed.");
		    break;
		}
		if(Lock[vehicleid] == 1)
		{   
		    Lock[vehicleid] = 0;
		    SendClientMessage(playerid,COLOR_GREEN," Car open.");
		    break;
		}
	}
	return 1;
	}
Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
	if (Lock[vehicleid] == 1)
	{
		{
		Lock[vehicleid] = 0;
		SendClientMessage(playerid,COLOR_GREEN," Car open.");
		}
	}
}
Reply
#2

This is not your system, right?

Seriously, look at the script:

pawn Код:
Lock[vehicleid] = 0;
What do you think this line does?
Dont know? Look at the following line:

pawn Код:
SendClientMessage(playerid,COLOR_GREEN," Car open.");
Yes, exactly, it opens the doors of vehicleid.

So you want them to open on death or disconnect. Have you heard of callbacks? If not, search in the wiki wiki.sa-mp.com
Telling you even more what to do would be lame.
Reply
#3

Код:
public OnPlayerDisconnect(playerid, reason)
{
	new vehid = GetPlayerVehicleID(playerid);
	new state = GetPlayerState(playerid);
	if(state = PLAYER_STATE_DRIVER)
	{
		Lock[vehid] = 0;
		SendClientMessage(playerid,0xF11111,"Car open!");
	}
	return 1;
}
errors :

Код:
E:\pwn(479) : error 001: expected token: "-identifier-", but found "state"
E:\.pwn(480) : error 001: expected token: "-identifier-", but found "="
E:\.pwn(480) : warning 215: expression has no effect
E:\.pwn(480) : error 001: expected token: ";", but found ")"
E:\.pwn(480) : error 029: invalid expression, assumed zero
E:\.pwn(480) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.
Reply
#4

A good start, but the problem is that you compare with a single = in the if. In pawn, a single = is used only to assign values to an variable. To compare them, use double =
Another minor mistake is that 'state' is a pawn keyword and you cant use it as variable name, just change it like this and it will work.

pawn Код:
new playerstate = GetPlayerState(playerid);   // Assigning the value to the variable, so a single = is correct
if(playerstate == PLAYER_STATE_DRIVER)     //to check if two values are equal use two =
Reply
#5

Its work, thank you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)