SA-MP Forums Archive
need help with lock - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: need help with lock (/showthread.php?tid=73561)



need help with lock - oreniko - 16.04.2009

i put this script

Код:
 	if (strcmp(cmdtext, "/lock", true)==0)
	{
	    new State;
	    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;
	}
and it gives me these errors

Код:
C:\Documents and Settings\a\Desktop\cstest.pwn(2439) : warning 217: loose indentation
C:\Documents and Settings\a\Desktop\cstest.pwn(2448) : error 017: undefined symbol "X"
C:\Documents and Settings\a\Desktop\cstest.pwn(2449) : error 017: undefined symbol "X"
C:\Documents and Settings\a\Desktop\cstest.pwn(2451) : warning 217: loose indentation
C:\Documents and Settings\a\Desktop\cstest.pwn(2455) : warning 217: loose indentation
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
what should i do?


Re: need help with lock - 56avenue - 16.04.2009

Код:
new Float:X, Float:Y, Float:Z;



Re: need help with lock - OmeRinG - 16.04.2009

I know it's kinda off-topic but you wrote too many lines! and made things that could lag your server....
just do this:
pawn Код:
if (!strcmp(cmdtext, "/lock", true))
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You're not in a vehicle!");
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid,COLOR_GREY,"You can only lock the doors as the driver.");
    SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),playerid, 0, 1);
    SendClientMessage(playerid, COLOR_GREY, "Vehicle locked!");
    PlayerPlaySound(playerid,1056,0,0,0);
    return 1;
}



Re: need help with lock - MenaceX^ - 16.04.2009

Quote:
Originally Posted by OmeRinG
I know it's kinda off-topic but you wrote too many lines! and made things that could lag your server....
just do this:
pawn Код:
if (!strcmp(cmdtext, "/lock", true))
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You're not in a vehicle!");
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid,COLOR_GREY,"You can only lock the doors as the driver.");
    SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),playerid, 0, 1);
    SendClientMessage(playerid, COLOR_GREY, "Vehicle locked!");
    PlayerPlaySound(playerid,1056,0,0,0);
    return 1;
}
It's not really can lag his server..


Re: need help with lock - OmeRinG - 16.04.2009

Quote:
Originally Posted by MenaceX^
Quote:
Originally Posted by OmeRinG
I know it's kinda off-topic but you wrote too many lines! and made things that could lag your server....
just do this:
pawn Код:
if (!strcmp(cmdtext, "/lock", true))
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You're not in a vehicle!");
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid,COLOR_GREY,"You can only lock the doors as the driver.");
    SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),playerid, 0, 1);
    SendClientMessage(playerid, COLOR_GREY, "Vehicle locked!");
    PlayerPlaySound(playerid,1056,0,0,0);
    return 1;
}
It's not really can lag his server..
He made a for loop just to check if i equals playerid.....


Re: need help with lock - Weirdosport - 16.04.2009

You need a loop for this script to work. Your command would lock the players car from the player who types /lock

Everyone else of the server could get in it.