SA-MP Forums Archive
/lock BUG - NEED 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: /lock BUG - NEED HELP! (/showthread.php?tid=358843)



/lock BUG - NEED HELP! - UnknownGamer - 11.07.2012

Код:
if (strcmp(cmdtext, "/lock", true)==0)
	{
		if(IsPlayerInAnyVehicle(playerid))
		{
			State=GetPlayerState(playerid);
			if(State!=PLAYER_STATE_DRIVER)
			{
				SendClientMessage(playerid,COLOR_GREY,"You can only lock the doors as the driver.");
				return 1;
			}
			new i;
			for(i=0;i<MAX_PLAYERS;i++)
			{
				if(i != playerid)
				{
					SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
				}
			}
			SendClientMessage(playerid, COLOR_GREY, "Vehicle locked!");
			GetPlayerPos(playerid,X,Y,Z);
			PlayerPlaySound(playerid,1056,X,Y,Z);
		}
		else
		{
			SendClientMessage(playerid, COLOR_GREY, "You're not in a vehicle!");
		}
	return 1;
	}
These are the error's I'm getting: (Anyone know how to fix)?

Код:
C:\Users\matthew\Desktop\New Generation LS;RP 2012 Server\gamemodes\larp.pwn(42251) : error 017: undefined symbol "State"
C:\Users\matthew\Desktop\New Generation LS;RP 2012 Server\gamemodes\larp.pwn(42252) : error 017: undefined symbol "State"
C:\Users\matthew\Desktop\New Generation LS;RP 2012 Server\gamemodes\larp.pwn(42266) : error 017: undefined symbol "X"
C:\Users\matthew\Desktop\New Generation LS;RP 2012 Server\gamemodes\larp.pwn(42267) : error 017: undefined symbol "X"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.



Re: /lock BUG - NEED HELP! - Larceny - 11.07.2012

You forgot to define the variables.
pawn Код:
if(strcmp(cmdtext, "/lock", true)==0)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new State = GetPlayerState(playerid);
        new Float:X, Float:Y, Float:Z;
        // ^
        if(State!=PLAYER_STATE_DRIVER)
        {
            SendClientMessage(playerid,COLOR_GREY,"You can only lock the doors as the driver.");
            return 1;
        }
        new i;
        for(i=0;i<MAX_PLAYERS;i++)
        {
            if(i != playerid)
            {
                SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
            }
        }
        SendClientMessage(playerid, COLOR_GREY, "Vehicle locked!");
        GetPlayerPos(playerid,X,Y,Z);
        PlayerPlaySound(playerid,1056,X,Y,Z);
    }
    else
    {
        SendClientMessage(playerid, COLOR_GREY, "You're not in a vehicle!");
    }
    return 1;
}



Re: /lock BUG - NEED HELP! - Roko_foko - 11.07.2012

EDIT:too slow


Re: /lock BUG - NEED HELP! - UnknownGamer - 11.07.2012

I got vehicle locked on game, but the car is still open and can get in?? I thought this should of locked it?


Re: /lock BUG - NEED HELP! - Larceny - 11.07.2012

pawn Код:
//...
        new i;
        for(i=0;i<MAX_PLAYERS;i++)
        {
            if(i != playerid)
            {
                SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
            }
        }
//...
The vehicle won't lock for who used the command.


Re: /lock BUG - NEED HELP! - UnknownGamer - 11.07.2012

Quote:
Originally Posted by RuiGy
Посмотреть сообщение
pawn Код:
//...
        new i;
        for(i=0;i<MAX_PLAYERS;i++)
        {
            if(i != playerid)
            {
                SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
            }
        }
//...
The vehicle won't lock for who used the command.
How would I make that work? - To actually lock the car?


Re: /lock BUG - NEED HELP! - Larceny - 11.07.2012

Just remove it:
pawn Код:
if(i != playerid)
{

}
pawn Код:
if(strcmp(cmdtext, "/lock", true)==0)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new State = GetPlayerState(playerid);
        new Float:X, Float:Y, Float:Z;
        // ^
        if(State!=PLAYER_STATE_DRIVER)
        {
            SendClientMessage(playerid,COLOR_GREY,"You can only lock the doors as the driver.");
            return 1;
        }
        new i;
        for(i=0;i<MAX_PLAYERS;i++)
        {
            SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
        }
        SendClientMessage(playerid, COLOR_GREY, "Vehicle locked!");
        GetPlayerPos(playerid,X,Y,Z);
        PlayerPlaySound(playerid,1056,X,Y,Z);
    }
    else
    {
        SendClientMessage(playerid, COLOR_GREY, "You're not in a vehicle!");
    }
    return 1;
}
Now it will lock for everybody, also who used command.


Re: /lock BUG - NEED HELP! - UnknownGamer - 11.07.2012

When I use that code, Anybody can lock my car, plus.... I have a car system so when I lock my second car, the first car unlocks? Should that happen.........


Re: /lock BUG - NEED HELP! - Larceny - 11.07.2012

The code there's nothing about a system of cars, second car, etc... You must add it to the command.