SA-MP Forums Archive
[COMPILE ERROR] VEH Command - 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: [COMPILE ERROR] VEH Command (/showthread.php?tid=338709)



[COMPILE ERROR] VEH Command - NewerthRoleplay - 30.04.2012

Heres my VEH command
pawn Код:
CMD:veh(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] => 3)
    {
    new vehid;
    new Float:x, Float:y, Float:z;
    if(sscanf(params, "u", vehid)) return SendClientMessage(playerid, COLOR_RED, "Use /veh [vehicle id]");
    else
    {
    GetPlayerPos(playerid, x, y, z);
    CreateVehicle(vehid, x, y, z, 82.2873, 0, 0, 0);
    )
    }
    else SendClientMessage(playerid, COLOR_RED, " ** You must be a level 3 Admin to use that! ");
    return 1;
}
And the errors that i am getting are:
pawn Код:
C:\Users\Rob\Documents\PAWNO\gamemodes\NRP.pwn(527) : warning 211: possibly unintended assignment
C:\Users\Rob\Documents\PAWNO\gamemodes\NRP.pwn(527) : error 029: invalid expression, assumed zero
C:\Users\Rob\Documents\PAWNO\gamemodes\NRP.pwn(527) : warning 215: expression has no effect
C:\Users\Rob\Documents\PAWNO\gamemodes\NRP.pwn(527) : error 001: expected token: ";", but found ")"
C:\Users\Rob\Documents\PAWNO\gamemodes\NRP.pwn(527) : error 029: invalid expression, assumed zero
C:\Users\Rob\Documents\PAWNO\gamemodes\NRP.pwn(527) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 * * Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.



Re: [COMPILE ERROR] VEH Command - Youice - 30.04.2012

can you show the lines which contains the errors?


Re: [COMPILE ERROR] VEH Command - NewerthRoleplay - 30.04.2012

They are the lines im not stupid thats why i posted the whole command in which the line 527 is situated :P


Re: [COMPILE ERROR] VEH Command - Youice - 30.04.2012

I compiled this and it worked try it (it should work)::

Код:
CMD:veh(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 3)
    {
    	new vehid;
    	new Float:x, Float:y, Float:z;
    	if(sscanf(params, "u", vehid)) return SendClientMessage(playerid, COLOR_RED, "Use /veh [vehicle id]");
    	else
    	{
    		GetPlayerPos(playerid, x, y, z);
    		CreateVehicle(vehid, x, y, z, 82.2873, 0, 0, 0);
    		return 1;
	}
    }
    else return SendClientMessage(playerid, COLOR_RED, " ** You must be a level 3 Admin to use that! ");
}



Re: [COMPILE ERROR] VEH Command - Youice - 30.04.2012

Quote:
Originally Posted by NewerthRoleplay
Посмотреть сообщение
They are the lines im not stupid thats why i posted the whole command in which the line 527 is situated :P
you just showed the code with it errors , okay thats nice but how could I know the line which contain its certain error?


Re: [COMPILE ERROR] VEH Command - Max_Coldheart - 30.04.2012

Quote:
Originally Posted by Youice
Посмотреть сообщение
you just showed the code with it errors , okay thats nice but how could I know the line which contain its certain error?
Check errors + Check code --> See error lines


Re: [COMPILE ERROR] VEH Command - MP2 - 30.04.2012

'return' stops the code - therefore 'else' is a waste:

pawn Код:
CMD:veh(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_RED, " ** You must be a level 3 Admin to use that! ");
    if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "Use /veh [vehicle id]");
    if(strval(params) < 400 || strval(params) > 611) return SendClientMessage(playerid, COLOR_RED, "Invalid vehicle model.");
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    CreateVehicle(strval(params), x+2, y+2, z, 90.0, 0, 0, 0);
    return 1;
}
- You put a ( after the CreateVehicle line, it should have been a }.
- Coordinates shifted so vehicle doesn't spawn on top of players.
- Sscanf removed - no need if there's only one parameter (also 'u' is a PLAYER, it won't work for a vehicle ID.


Re: [COMPILE ERROR] VEH Command - NewerthRoleplay - 30.04.2012

Quote:
Originally Posted by MP2
Посмотреть сообщение
'return' stops the code - therefore 'else' is a waste:

pawn Код:
CMD:veh(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_RED, " ** You must be a level 3 Admin to use that! ");
    if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "Use /veh [vehicle id]");
    if(strval(params) < 400 || strval(params) > 611) return SendClientMessage(playerid, COLOR_RED, "Invalid vehicle model.");
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    CreateVehicle(strval(params), x+2, y+2, z, 90.0, 0, 0, 0);
    return 1;
}
- You put a ( after the CreateVehicle line, it should have been a }.
- Coordinates shifted so vehicle doesn't spawn on top of players.
- Sscanf removed - no need if there's only one parameter (also 'u' is a PLAYER, it won't work for a vehicle ID.
Thanks MP2 you actually helped apart from people who just paste some code and say "There" you actually explain where i am going wrong so thank you <3


P.S. I am making NOOB mistakes as i have a mac and coding on a mac and compiling for some reason at only 64 bytes is kinda weird and frustrating -.-, To compile i have to explain and send it to my friends