SA-MP Forums Archive
must be a variable. Assumed 0. How to solve this? - 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)
+--- Thread: must be a variable. Assumed 0. How to solve this? (/showthread.php?tid=377446)



must be a variable. Assumed 0. How to solve this? - HeLiOn_PrImE - 14.09.2012

I am trying to build a command to attach the camera to your car. but i get this:

Код:
C:\Users\HeLiOn\Desktop\camtest.pwn(42) : error 008: must be a constant expression; assumed zero
C:\Users\HeLiOn\Desktop\camtest.pwn(42) : error 029: invalid expression, assumed zero
C:\Users\HeLiOn\Desktop\camtest.pwn(42) : error 029: invalid expression, assumed zero
C:\Users\HeLiOn\Desktop\camtest.pwn(42) : fatal error 107: too many error messages on one line
The code is below. I bolded the line 42. How can I solve this?

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/camtest", cmdtext, true, 10) == 0)
	{
	    new p = GetPlayerVehicleID(playerid);
	    new campos[playerid] = CreatePlayerObject(playerid,19300, 0., 0,0, 0.0000, -1, -1, 100);
            AttachPlayerObjectToVehicle(playerid,campos[playerid],p,0.0, 0.0, 5.510000, 0.000000, 0.000000, 0.000000);
	    AttachCameraToPlayerObject(playerid,campos[playerid]);
	}
	if (strcmp("/resetcam", cmdtext, true, 10) == 0)
	{
	    DestroyObject(object[playerid]);
	    return 1;
	}
	return 0;
}



Re: must be a variable. Assumed 0. How to solve this? - Rudy_ - 14.09.2012

pawn Код:
new campos[playerid] = CreatePlayerObject(playerid,19300, 0.0, 0,0, 0.0000, -1, -1, 100);



Re: must be a variable. Assumed 0. How to solve this? - HeLiOn_PrImE - 14.09.2012

I still get the errors, but the 3rd now is:
Код:
C:\Users\HeLiOn\Desktop\camtest.pwn(42) : error 036: empty statement



Re: must be a variable. Assumed 0. How to solve this? - Vince - 14.09.2012

Your code doesn't make any sense. To access an index of an array, the array must have been created priorly. In your next command you also use object[playerid]. (?)


Re: must be a variable. Assumed 0. How to solve this? - HeLiOn_PrImE - 14.09.2012

ok I solved the error problem.

Now, is there a way to make the camera look at an object? I can make it look at some coords, but the player can be anywhere on the map, so I can't really use that. How can I controll the attached camera direction?