SA-MP Forums Archive
declaration of a local variable must appear in a compound block and defined symbols apparently undefined - 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: declaration of a local variable must appear in a compound block and defined symbols apparently undefined (/showthread.php?tid=160096)



declaration of a local variable must appear in a compound block and defined symbols apparently undefined - braduz - 15.07.2010

Apparently vehicle id is not defined aswell as newkeys
public update(playerid)
Код:
{
 if(IsPlayerInRangeOfPoint(playerid, 4.0, 116.7310,1853.2793,17.7055))
    {
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "you are not in a vehicle!");
	 {
	 if (HOLDING( KEY_FIRE ))
 new vehicleid = GetPlayerVehicleID(playerid);
PlayerPlaySound(playerid, 1133, 116.7310,1853.2793,17.7055);
SetVehicleHealth(vehicleid, 1000.0);
RepairVehicle(vehicleid);
SendClientMessage(playerid, COLOR_BRIGHTRED, "Your vehicle has been repaired.");
	}
   }
    return 1;
}



Re: declaration of a local variable must appear in a compound block and defined symbols apparently undefined - armyoftwo - 15.07.2010

Код:
public update(playerid)
{
  if(IsPlayerInRangeOfPoint(playerid, 4.0, 116.7310,1853.2793,17.7055))
  {
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "you are not in avehicle!");
    else if (HOLDING( KEY_FIRE ))
    {
    new vehicleid = GetPlayerVehicleID(playerid);
    PlayerPlaySound(playerid, 1133, 116.7310,1853.2793,17.7055);
    SetVehicleHealth(vehicleid, 1000.0);
    RepairVehicle(vehicleid);
    SendClientMessage(playerid, COLOR_BRIGHTRED, "Your vehicle has been repaired.");
    }
  }
  return 1;
}



Re: declaration of a local variable must appear in a compound block and defined symbols apparently undefined - braduz - 15.07.2010

C:\Users\owner\Desktop\New folder\gamemodes\tAxIFRB.pwn(5409) : error 017: undefined symbol "newkeys"


Re: declaration of a local variable must appear in a compound block and defined symbols apparently undefined - armyoftwo - 15.07.2010

you need to place the code under OnPlayerKeyStateChange or define newkeys


Re: declaration of a local variable must appear in a compound block and defined symbols apparently undefined - braduz - 15.07.2010

Quote:
Originally Posted by armyoftwo
Посмотреть сообщение
you need to place the code under OnPlayerKeyStateChange or define newkeys
how, its already under there, and needs to be there for it to work


Re: declaration of a local variable must appear in a compound block and defined symbols apparently undefined - Toni - 15.07.2010

then define newkeys as a key whatever


Re: declaration of a local variable must appear in a compound block and defined symbols apparently undefined - braduz - 15.07.2010

thanks! but the script keeps repairing when the button has not been pressed ;/


Re: declaration of a local variable must appear in a compound block and defined symbols apparently undefined - Sergei - 15.07.2010

Код:
SetVehicleHealth(vehicleid, 1000.0);
RepairVehicle(vehicleid);
You don't need to set health manually, RepairVehicle already does that.


Re: declaration of a local variable must appear in a compound block and defined symbols apparently undefined - armyoftwo - 15.07.2010

here
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
 if (PRESSED(KEY_FIRE))
 {
    if(IsPlayerInRangeOfPoint(playerid, 4.0, 116.7310,1853.2793,17.7055))
    {
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "you are not in avehicle!");
    new vehicleid = GetPlayerVehicleID(playerid);
    PlayerPlaySound(playerid, 1133, 116.7310,1853.2793,17.7055);
    RepairVehicle(vehicleid);
    SendClientMessage(playerid, COLOR_BRIGHTRED, "Your vehicle has been repaired.");
    }
 }
 return 1;
}
I told you to move it under onplayerkeystatechange
tell me if this works


Re: declaration of a local variable must appear in a compound block and defined symbols apparently undefined - braduz - 15.07.2010

Quote:
Originally Posted by armyoftwo
Посмотреть сообщение
here
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
 if (PRESSED(KEY_FIRE))
 {
    if(IsPlayerInRangeOfPoint(playerid, 4.0, 116.7310,1853.2793,17.7055))
    {
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "you are not in avehicle!");
    new vehicleid = GetPlayerVehicleID(playerid);
    PlayerPlaySound(playerid, 1133, 116.7310,1853.2793,17.7055);
    RepairVehicle(vehicleid);
    SendClientMessage(playerid, COLOR_BRIGHTRED, "Your vehicle has been repaired.");
    }
 }
 return 1;
}
I told you to move it under onplayerkeystatechange
tell me if this works
Im starting to think this is a glitch, if I use W or S in the area it repairs, thats not the shoot button