PDA

View Full Version : What's wrong here?


Cjgogo
29/08/2011, 07:57 AM
new CPTL1;
new CPTL2;
new CPTR1;
new CPTL3;
new CPFW1;
new CPTL4;
new CPTR2;
new CPFW2;
new CPTL5;
new FNCP;

public OnPlayerEnterDynamicRaceCP(playerid,checkpointid)
{
if(checkpointid == CPTL1) return DestroyDynamicRaceCP(CPTL1) && CPTL2 = CreateDynamicRaceCP(0,-2521.5483,1080.5056,55.6387,-2527.1306,569.7551,14.2614,2.0,-1,-1,-1,60.0);
if(checkpointid == CPTL2) return DestroyDynamicRaceCP(CPTL2) && CPTR1 = CreateDynamicRaceCP(0,-2527.1306,569.7551,14.2614,-2748.5134,567.6544,14.2010,2.0,-1,-1,-1,60.0);
if(checkpointid == CPTR1) return DestroyDynamicRaceCP(CPTR1) && CPTL3 = CreateDynamicRaceCP(0,-2748.5134,567.6544,14.2010,-2705.9546,314.2898,3.9802,2.0,-1,-1,-1,60.0);
if(checkpointid == CPTL3) return DestroyDynamicRaceCP(CPTL3) && CPFW1 = CreateDynamicRaceCP(0,-2705.9546,314.2898,3.9802,-2706.7883,163.5176,4.0700,2.0,-1,-1,-1,60.0);
if(checkpointid == CPFW1) return DestroyDynamicRaceCP(CPFW1) && CPTL4 = CreateDynamicRaceCP(0,-2706.7883,163.5176,4.0700,-2252.5396,320.5182,34.9710,2.0,-1,-1,-1,60.0);
if(checkpointid == CPTL4) return DestroyDynamicRaceCP(CPTL4) && CPTR2 = CreateDynamicRaceCP(0,-2252.5396,320.5182,34.9710,-2251.9275,140.9347,34.9724,2.0,-1,-1,-1,60.0);
if(checkpointid == CPTR2) return DestroyDynamicRaceCP(CPTR2) && CPFW2 = CreateDynamicRaceCP(0,-2251.9275,140.9347,34.9724,-2257.1306,-59.0355,34.9718,2.0,-1,-1,-1,60.0);
if(checkpointid == CPFW2) return DestroyDynamicRaceCP(CPFW2) && CPTL5 = CreateDynamicRaceCP(0,-2257.1306,-59.0355,34.9718,-2048.0027,-97.0938,34.9680,2.0,-1,-1,-1,60.0);
if(checkpointid == CPTL5) return DestroyDynamicRaceCP(CPTL5) && FNCP = CreateDynamicRaceCP(1,-2048.0027,-97.0938,34.9680,-2048.0027,-97.0938,34.9680,2.0,-1,-1,-1,60.0);
if(checkpointid == FNCP)
{
new vehicleid=GetPlayerVehicleID(playerid);
if(gFailed[playerid] == 1) return GivePlayerMoney(playerid,200) && DestroyVehicle(vehicleid) && SendClientMessage(playerid,COLOR_RED,"You failed,come back to claim your license later");
if(gFailed[playerid] == 0)
{
SendClientMessage(playerid,COLOR_GREEN,"Congratulation,you passed the test,you have now a driving-license,and can explore the roads,without being afraid of cops");
PlayerPlaySound(playerid,1098,0,0,0);
GivePlayerMoney(playerid,500);
new string[128];
format(string,sizeof(string),"Statistics:Your time was %d seconds,congratulatione,you would be a fast cop",countn4);
if(countn4 < 180) return KillTimer(counttimer4);
}
}
return 1;
}
Errors:
D:\Jocuri\GTA\GTA SA\GTA San Andreas\samp03csvr_R5_win32\gamemodes\sfcnr.pwn(61 5) : error 022: must be lvalue (non-constant)
D:\Jocuri\GTA\GTA SA\GTA San Andreas\samp03csvr_R5_win32\gamemodes\sfcnr.pwn(61 6) : error 022: must be lvalue (non-constant)
D:\Jocuri\GTA\GTA SA\GTA San Andreas\samp03csvr_R5_win32\gamemodes\sfcnr.pwn(61 7) : error 022: must be lvalue (non-constant)
D:\Jocuri\GTA\GTA SA\GTA San Andreas\samp03csvr_R5_win32\gamemodes\sfcnr.pwn(61 8) : error 022: must be lvalue (non-constant)
D:\Jocuri\GTA\GTA SA\GTA San Andreas\samp03csvr_R5_win32\gamemodes\sfcnr.pwn(61 9) : error 022: must be lvalue (non-constant)
D:\Jocuri\GTA\GTA SA\GTA San Andreas\samp03csvr_R5_win32\gamemodes\sfcnr.pwn(62 0) : error 022: must be lvalue (non-constant)
D:\Jocuri\GTA\GTA SA\GTA San Andreas\samp03csvr_R5_win32\gamemodes\sfcnr.pwn(62 1) : error 022: must be lvalue (non-constant)
D:\Jocuri\GTA\GTA SA\GTA San Andreas\samp03csvr_R5_win32\gamemodes\sfcnr.pwn(62 2) : error 022: must be lvalue (non-constant)
D:\Jocuri\GTA\GTA SA\GTA San Andreas\samp03csvr_R5_win32\gamemodes\sfcnr.pwn(62 3) : error 022: must be lvalue (non-constant)
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


Error lines are the if(cpid == x) return Code;the rest is ok

Hiddos
29/08/2011, 09:18 AM
Most probably:
return DestroyDynamicRaceCP(CPTL5) && FNCP = CreateDynamicRaceCP(1,-2048.0027,-97.0938,34.9680,-2048.0027,-97.0938,34.9680,2.0,-1,-1,-1,60.0);

I hardly believe stuff like that will work.

Bakr
29/08/2011, 09:24 AM
Yes, this is invalid Pawn syntax:

if(checkpointid == CPTL1) return DestroyDynamicRaceCP(CPTL1) && CPTL2 = CreateDynamicRaceCP(0,-2521.5483,1080.5056,55.6387,-2527.1306,569.7551,14.2614,2.0,-1,-1,-1,60.0);


First, in case you didn't know, Pawn only returns one value. However, you can have it multiple calls after the return statement, separating them by commas:

if(checkpointid == CPTL1) return DestroyDynamicRaceCP(CPTL1), CPTL2 = CreateDynamicRaceCP(0,-2521.5483,1080.5056,55.6387,-2527.1306,569.7551,14.2614,2.0,-1,-1,-1,60.0);


Also note that the following does the same:

if(checkpointid == CPTL1)
{
CPTL2 = CreateDynamicRaceCP(0,-2521.5483,1080.5056,55.6387,-2527.1306,569.7551,14.2614,2.0,-1,-1,-1,60.0);
return DestroyDynamicRaceCP(CPTL1);
}


You could even do this, considering it doesn't matter what DestroyDynamicRaceCP returns:

if(checkpointid == CPTL1)
{
CPTL2 = CreateDynamicRaceCP(0,-2521.5483,1080.5056,55.6387,-2527.1306,569.7551,14.2614,2.0,-1,-1,-1,60.0);
DestroyDynamicRaceCP(CPTL1);
return 1;
}


I suggest reading over the pawn_lang.pdf.

Cjgogo
29/08/2011, 02:17 PM
thanks for help,bakr,after I sued ur way evrything is OK but the checkpoints are created until CTL3 WTF?:O

if(checkpointid == CPTL1) { CPTL2 = CreateDynamicRaceCP(0,-2521.5483,1080.5056,55.6387,-2527.1306,569.7551,14.2614,2.0,-1,-1,-1,60.0); DestroyDynamicRaceCP(CPTL1); return true; }
if(checkpointid == CPTL2) { CPTR1 = CreateDynamicRaceCP(0,-2527.1306,569.7551,14.2614,-2748.5134,567.6544,14.2010,2.0,-1,-1,-1,60.0); DestroyDynamicRaceCP(CPTL2); return true; }
if(checkpointid == CPTR1) { CPTL3 = CreateDynamicRaceCP(0,-2748.5134,567.6544,14.2010,-2705.9546,314.2898,3.9802,2.0,-1,-1,-1,60.0); DestroyDynamicRaceCP(CPTR1); return true; }
if(checkpointid == CPTL3) { CPFW1 = CreateDynamicRaceCP(0,-2705.9546,314.2898,3.9802,-2706.7883,163.5176,4.0700,2.0,-1,-1,-1,60.0); DestroyDynamicRaceCP(CPTL3); return true; }
if(checkpointid == CPFW1) { CPTL4 = CreateDynamicRaceCP(0,-2706.7883,163.5176,4.0700,-2252.5396,320.5182,34.9710,2.0,-1,-1,-1,60.0); DestroyDynamicRaceCP(CPFW1); return true; }
if(checkpointid == CPTL4) { CPTR2 = CreateDynamicRaceCP(0,-2252.5396,320.5182,34.9710,-2251.9275,140.9347,34.9724,2.0,-1,-1,-1,60.0); DestroyDynamicRaceCP(CPTL4); return true; }
if(checkpointid == CPTR2) { CPFW2 = CreateDynamicRaceCP(0,-2251.9275,140.9347,34.9724,-2257.1306,-59.0355,34.9718,2.0,-1,-1,-1,60.0); DestroyDynamicRaceCP(CPTR2); return true; }
if(checkpointid == CPFW2) { CPTL5 = CreateDynamicRaceCP(0,-2257.1306,-59.0355,34.9718,-2048.0027,-97.0938,34.9680,2.0,-1,-1,-1,60.0); DestroyDynamicRaceCP(CPFW2); return true; }
if(checkpointid == CPTL5) { FNCP = CreateDynamicRaceCP(1,-2048.0027,-97.0938,34.9680,-2048.0027,-97.0938,34.9680,2.0,-1,-1,-1,60.0); DestroyDynamicRaceCP(CPTL5); return true; }

The mostannoying thing is actually it doesn't manke any fucking sense,as until that checkpoint evrything goes OK