Errors on newkeys
#1

i want to make LCTRL as /tow (bind) but i getting annoying errors...


Код:
CMD:tow(playerid, params[])
{
//    if ((oldkeys & KEY_FIRE) && !(newkeys & KEY_FIRE))
	if (newkeys == KEY_FIRE) && (GetVehicleModel(GetPlayerVehicleID(playerid)) == 525) && (GetPlayerState(playerid) == PLAYER_STATE_DRIVER))
 	if(IsACop(playerid))
   		if(IsPlayerInAnyVehicle(playerid))
     	{
			new
				carid = GetPlayerVehicleID(playerid);

			if(IsATowTruck(carid))
			{
   				new
					closestcar = GetClosestCar(playerid, carid);

       			if(GetDistanceToCar(playerid,closestcar) <= 8 && !IsTrailerAttachedToVehicle(carid)) {
					foreach(Player, i) {
						if(GetPlayerVehicle(i, closestcar) != -1) {
						    if(ProxDetectorS(30.0,playerid,i))
								SendClientMessageEx(i, COLOR_LIGHTBLUE, "Someone is attempting to tow your vehicle away!");

							arr_Towing[playerid] = closestcar;
						    SendClientMessageEx(playerid, COLOR_GRAD2, "This player owned vehicle is available for impounding.");
      						return AttachTrailerToVehicle(closestcar,carid);
						}
					}
					SendClientMessageEx(playerid, COLOR_GRAD2, "This vehicle has no registration, it is available for impounding.");
					AttachTrailerToVehicle(closestcar,carid);
					arr_Towing[playerid] = closestcar;
					return 1;
     			}
			}
			else SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to tow with this vehicle.");
   		}
     	else SendClientMessageEx(playerid, COLOR_GRAD2, "You need to be inside a vehicle to use this command!");
	}
   	else SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use this command.");
	return 1;
}
Errors:
Код:
C:\Users\Mor\Desktop\CGRP v1.0\CGRP v1.0\gamemodes\CGRP.pwn(31186) : error 017: undefined symbol "newkeys"
C:\Users\Mor\Desktop\CGRP v1.0\CGRP v1.0\gamemodes\CGRP.pwn(31186) : error 029: invalid expression, assumed zero
C:\Users\Mor\Desktop\CGRP v1.0\CGRP v1.0\gamemodes\CGRP.pwn(31186) : warning 215: expression has no effect
C:\Users\Mor\Desktop\CGRP v1.0\CGRP v1.0\gamemodes\CGRP.pwn(31186) : error 001: expected token: ";", but found ")"
C:\Users\Mor\Desktop\CGRP v1.0\CGRP v1.0\gamemodes\CGRP.pwn(31186) : fatal error 107: too many error messages on one line

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


4 Errors.
Line 31186:
Код:
if (newkeys == KEY_FIRE) && (GetVehicleModel(GetPlayerVehicleID(playerid)) == 525) && (GetPlayerState(playerid) == PLAYER_STATE_DRIVER))
please help..
Reply
#2

Everything in an if statements has to go between brackets.
pawn Код:
if( /* ALL stuff here */ )
You might also want to add more braces and fix your identation.
Reply
#3

Quote:

CMD:tow(playerid, params[])
{
if (newkeys == KEY_FIRE) && (GetVehicleModel(GetPlayerVehicleID(playerid)) == 525) && (GetPlayerState(playerid) == PLAYER_STATE_DRIVER) IsACop(playerid) (IsPlayerInAnyVehicle(playerid)))
{
new
carid = GetPlayerVehicleID(playerid);

if(IsATowTruck(carid))
{
new
closestcar = GetClosestCar(playerid, carid);

if(GetDistanceToCar(playerid,closestcar) <= 8 && !IsTrailerAttachedToVehicle(carid)) {
foreach(Player, i) {
if(GetPlayerVehicle(i, closestcar) != -1) {
if(ProxDetectorS(30.0,playerid,i))
SendClientMessageEx(i, COLOR_LIGHTBLUE, "Someone is attempting to tow your vehicle away!");

arr_Towing[playerid] = closestcar;
SendClientMessageEx(playerid, COLOR_GRAD2, "This player owned vehicle is available for impounding.");
return AttachTrailerToVehicle(closestcar,carid);
}
}
SendClientMessageEx(playerid, COLOR_GRAD2, "This vehicle has no registration, it is available for impounding.");
AttachTrailerToVehicle(closestcar,carid);
arr_Towing[playerid] = closestcar;
return 1;
}
}
else SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to tow with this vehicle.");
}
else SendClientMessageEx(playerid, COLOR_GRAD2, "You need to be inside a vehicle to use this command!");
}
else SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use this command.");
return 1;
}

Vince still same errors
Reply
#4

You can't use newkeys in a command. They are to be used in the OnPlayerKeyStateChange callback ONLY. You can just RETURN the command under that callback.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_FIRE)
    {
           // check other conditions, if he is in a car, etc..
           return cmd_tow(playerid);
    }
  return 1;
}
Reply
#5

Parameters:
pawn Код:
(playerid, params[])
You're using oldkeys and newkeys, but those are used in OnPlayerKeyStateChange.

@Rajat_Pawar
That would be:
pawn Код:
return cmd_tow(playerid, "");
Reply
#6

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Parameters:
pawn Код:
(playerid, params[])
You're using oldkeys and newkeys, but those are used in OnPlayerKeyStateChange.

@Rajat_Pawar
That would be:
pawn Код:
return cmd_tow(playerid, "");
Nah, I am sure you can omit "" (params) as a parameter if there are none, it works, (I have used it countless times) try it !
Reply
#7

After give it a try Under public OnPlayerKeyStateChange Pawn Compiler has stoppped working.

Quote:

if(newkeys & KEY_FIRE)
{
if(IsPlayerInAnyVehicle(playerid) || IsACop(playerid) || GetVehicleModel(vehicleid) == 425 && GetPlayerState(playerid) == PLAYER_STATE_DRIVER))
return cmd_tow(playerid, params[]);
}
return 1;
}

anyone?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)