[COMPILE ERROR] VEH Command
#1

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.
Reply
#2

can you show the lines which contains the errors?
Reply
#3

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

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! ");
}
Reply
#5

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?
Reply
#6

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
Reply
#7

'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.
Reply
#8

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)