need help with lock
#1

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?
Reply
#2

Код:
new Float:X, Float:Y, Float:Z;
Reply
#3

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;
}
Reply
#4

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..
Reply
#5

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.....
Reply
#6

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)