What am I doing wrong (Command)?
#1

Basically, I was trying to make it so if you're in a vehicle it will put gold rims on it, otherwise it'll tell you you're not in a vehicle. I'm having an issue with it though. I guess my issue is I don't know how to make it save the user's vehicle id into a variable. How could I accomplish this? Thanks. (I'm trying to get used to variables and if else statements, probably looks like a big noob question, but I'd appreciate any help you can give).

Код:
CMD:goldrims(playerid, params[])
{
	GetPlayerVehicleID(playerid);
	
	if(IsPlayerInVehicle(playerid, vehicleid));
	{
		AddVehicleComponent(GetPlayerVehicleID(playerid), 1080);
		SendClientMessage(playerid, COLOR_RED, "You have put gold rims on the vehicle!");
	}
	else
	{
	    SendClientMessage(playerid, COLOR_RED, "You're not in a vehicle!");
	}
	return 1;
}
Reply
#2

pawn Код:
CMD:goldrims(playerid, params[])
{  
    if(IsPlayerInAnyVehicle(playerid))
    {
        AddVehicleComponent (GetPlayerVehicleID (playerid), 1080);
        SendClientMessage (playerid, COLOR_RED, "You have put gold rims on the vehicle!");
    }
    else
    {
        SendClientMessage (playerid, COLOR_RED, "You're not in a vehicle!");
    }
    return 1;
}
Reply
#3

I was unaware of this function, so I switched it but I'm still getting errors. Why?

Код:
Errors:

C:\Users\Nolan\Desktop\Pawn Scripting\pawno\Roleplayscript.pwn(515) : error 036: empty statement
C:\Users\Nolan\Desktop\Pawn Scripting\pawno\Roleplayscript.pwn(520) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Код:
CMD:goldrims(playerid, params[])
{
	
	if(IsPlayerInAnyVehicle(playerid));
	{
		AddVehicleComponent(GetPlayerVehicleID(playerid), 1080);
		SendClientMessage(playerid, COLOR_RED, "You have put gold rims on the vehicle!");
	}
	else
	{
	    SendClientMessage(playerid, COLOR_RED, "You're not in a vehicle!");
	}
	return 1;
}
Reply
#4

pawn Код:
CMD:goldrims(playerid, params[])
{
    if(IsPlayerInAnyVehicle(playerid)) // In 'if' must not close the judgment.
    {
        AddVehicleComponent(GetPlayerVehicleID(playerid), 1080);
        SendClientMessage(playerid, COLOR_RED, "You have put gold rims on the vehicle!");
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You're not in a vehicle!");
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by EnzoMetlc
Посмотреть сообщение
pawn Код:
CMD:goldrims(playerid, params[])
{  
    if(IsPlayerInAnyVehicle(playerid))
    {
        AddVehicleComponent (GetPlayerVehicleID (playerid), 1080);
        SendClientMessage (playerid, COLOR_RED, "You have put gold rims on the vehicle!");
    }
    else
    {
        SendClientMessage (playerid, COLOR_RED, "You're not in a vehicle!");
    }
    return 1;
}
I literally just switched to this code, right before you posted this. I found the reason it wasn't working, the similar code I was using, I put a ; after if(IsPlayerInAnyVehicle(playerid)). Thanks for the help though.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)