Please help me with this bit of script
#1

I don't get why I am getting errors on this code:

Код:
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
	if(IsPlayerInArea(2, -14.6085,1689.5648,453.8858, 2128.3269));
	{
	  ();
	}
	else
	{
		if(IsPlayerInAnyVehicle(playerid))
  	{
    	if(newkeys &= 4)
    	{
      	new Float:ZAngle,Float:X,Float:Y,Float:Z,vehicleid;
      	vehicleid = GetPlayerVehicleID(playerid);
      	GetVehiclePos(vehicleid,X,Y,Z);
      	GetVehicleZAngle(vehicleid,ZAngle);
      	SetVehicleZAngle(vehicleid,ZAngle);
      	SetVehiclePos(vehicleid,X,Y,Z+2);
    	}
  	}
 	}
  return 1;
}

I am trying to make a code that lets the player use alt to flip their vehicle unless they are in a specific area. It's my first time using IsPlayerInArea so I might be making a bunch of noob errors
Reply
#2

What are the errors, and do you have your IsPlayerInArea stock handy, I've seen a few different ones over time..
Reply
#3

ya i forgot about the errors here they are:

Код:
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\filterscripts\SSnSCars.pwn(65) : error 017: undefined symbol "IsPlayerInArea"
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\filterscripts\SSnSCars.pwn(65) : error 036: empty statement
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\filterscripts\SSnSCars.pwn(67) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\filterscripts\SSnSCars.pwn(67) : error 001: expected token: ")", but found ";"
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\filterscripts\SSnSCars.pwn(69) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.
there were more than that but i fixed them.. cant fix the rest though


and as for the stock I dont know what you mean but here are the 4 saved positions around the area if that helps

AddPlayerClass(0,453.8858,2119.6646,27.3471,192.85 63,0,0,0,0,0,0); //
AddPlayerClass(0,64.7690,2128.3269,17.5648,41.1187 ,0,0,0,0,0,0); //
AddPlayerClass(0,-14.6085,1691.8516,16.9230,175.6624,0,0,0,0,0,0); //
AddPlayerClass(0,410.5251,1689.5648,33.9420,300.96 70,0,0,0,0,0,0); //
Reply
#4

Well IsPlayerInArea isn't built in, you have to put it there yourself. Do you have something somewhere that says:

pawn Код:
IsPlayerInArea(xmax, xmin, blah blah)
{
//some stuff
return //stuff
}
Also, is your area meant to be a square? If it is not a square it can complicate things a bit..
Reply
#5

ya it's meant to be a square.. those /save positions were sort of general because I dont have to be so specific
ill edit to say if i got it working
Reply
#6

"Rectangle Method"

Код:
______________x
|       |   ^
|       |   |
x______________|   N
With this method you need to pay attention to which was is North so you get the right values in the right places.

Go to the top right corner of your area (north east) and /save. Then do the same for the south west corner.

Exit the game and get the values as mentioned above.

You'll have something like:

10.0, 100.0, 5.0 - South West
50.0, 120.0, 6.0 - North East

Minimum x = 10.0
Maximum x = 50.0
Minimum y = 100.0
Maximum y = 120.0

_________________________________________________

Something I posted a while ago on getting the required co-ordinates.
Reply
#7

Thanks for ur latest post, I'll fix the coordinates after I get this code working. But anyways, I got it down to two errors with this:

http://pawno.pastebin.com/d7462046f

if ur wondering why i changed to a pastebin rather than using code, it's cause the indents were messed up when i used code. But anyways, got it down to 2 errors from 12 wow im proud.

Anyways canyou help me with the last two errors? here they are:

Код:
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\filterscripts\SSnSCars.pwn(73) : error 036: empty statement
C:\Documents and Settings\Administrator\Desktop\SAMP\sampserver\filterscripts\SSnSCars.pwn(74) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply
#8

Try this:

pawn Код:
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
    if(!IsPlayerInArea(playerid, Float:max_x, Float:min_x, Float:max_y, Float:min_y)) //if the player ISN'T in the area
    {
        if(IsPlayerInAnyVehicle(playerid)) //if the player is in a vehicle
        {
            if(newkeys & 4)
            {
                new Float:ZAngle,Float:X,Float:Y,Float:Z,vehicleid;
                vehicleid = GetPlayerVehicleID(playerid);
                GetVehiclePos(vehicleid,X,Y,Z);
                GetVehicleZAngle(vehicleid,ZAngle);
                SetVehicleZAngle(vehicleid,ZAngle);
                SetVehiclePos(vehicleid,X,Y,Z+2);
            }
        }
    }
  return 1;
}
I don't think &= is an operator, and I also added a ! to stop you needing the { } bit.

Note: You'll need to put in the values, you had 2 for the playerid for some reason.
Reply
#9

Thanks soo much for your help, especially for ur patients. Right now I am getting the coordinates again in game, I will edit to let others know if it worked or not.

Thanks again
Reply
#10

Quote:
Originally Posted by ThePS3Guy
Thanks soo much for your help, especially for ur patients. Right now I am getting the coordinates again in game, I will edit to let others know if it worked or not.

Thanks again
Not sure that it's patience, I just have waaay to much time on my hands what with it being the holidays
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)