ChangeVehicleColor
#1

How to make that, when vip sit in car and then car change colour ? i try to add like this, but its not working :

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(Account[playerid][Vip] == 1)
    {
        ChangeVehicleColor(vehicleid, 0, 1);
        SetTimer("ChangeColor", 2500, 0);
    }
}
pawn Код:
public ChangeColor(vehicleid)
{
    ChangeVehicleColor(vehicleid, 7, 3);
    ChangeVehicleColor(vehicleid, 5, 9);
    ChangeVehicleColor(vehicleid, 128, 7);
    ChangeVehicleColor(vehicleid, 3, 9);
    ChangeVehicleColor(vehicleid, 2, 7);
    ChangeVehicleColor(vehicleid, 31, 47);
    ChangeVehicleColor(vehicleid, 78, 71);
    ChangeVehicleColor(vehicleid, 28, 45);
    ChangeVehicleColor(vehicleid, 2, 5);
    ChangeVehicleColor(vehicleid, 30, 40);
    ChangeVehicleColor(vehicleid, 57, 98);
    return 1;
}
Someone know ? :S
Reply
#2

Your changecolor function will just set all the colors at once..

Try using SetTimerEx and use this for your timer:

Код:
SetTimerEx("ChangeColor",2500,1,"i",vehicleid);
Код:
//Top of script:
#define MAX_CARS 200 //you can change this..
new dunce[MAX_CARS] = 0;
//TIMER:
public ChangeColor(vehicleid)
{
	switch(dunce(vehicleid))
  	{
		case 0: ChangeVehicleColor(vehicleid, 7, 3);dunce[vehicleid]++;
		case 1: ChangeVehicleColor(vehicleid, 5, 9);dunce[vehicleid]++;
		case 2: ChangeVehicleColor(vehicleid, 128, 7);dunce[vehicleid]++;
		case 3: ChangeVehicleColor(vehicleid, 3, 9);dunce[vehicleid]++;
		case 4: ChangeVehicleColor(vehicleid, 31, 47);dunce[vehicleid]++;
		case 5: ChangeVehicleColor(vehicleid, 78, 71);dunce[vehicleid]++;
		case 6: ChangeVehicleColor(vehicleid, 28, 45);dunce[vehicleid]++;
		case 7: ChangeVehicleColor(vehicleid, 2, 5);dunce[vehicleid]++;
		case 8: ChangeVehicleColor(vehicleid, 30, 40);dunce[vehicleid]++;
		case 9: ChangeVehicleColor(vehicleid, 57, 98);dunce[vehicleid] = 0;
	}
    return 1;
}
Untested.
Reply
#3

pawn Код:
new var[ MAX_PLAYERS ], timer;
public OnPlayerStateChange( playerid, oldstate, newstate ) {
    if( newstate == PLAYER_STATE_DRIVER || Account[playerid][Vip] == 1 ) {
            ChangeVehicleColor(vehicleid, 0, 1); timer = SetTimerEx("ChangeColor", 2500, 1, "i", playerid); var[ playerid ] = 1;
    }
    return 1;
}
pawn Код:
forward ChangeColor(playerid);
public ChangeColor(playerid) {
    new vehicleid = GetPlayerVehicleID( playerid );
    ChangeVehicleColor(vehicleid, 7, 3); ChangeVehicleColor(vehicleid, 5, 9);
    ChangeVehicleColor(vehicleid, 128, 7); ChangeVehicleColor(vehicleid, 3, 9);
    ChangeVehicleColor(vehicleid, 2, 7); ChangeVehicleColor(vehicleid, 31, 47);
    ChangeVehicleColor(vehicleid, 78, 71); ChangeVehicleColor(vehicleid, 28, 45);
    ChangeVehicleColor(vehicleid, 2, 5); ChangeVehicleColor(vehicleid, 30, 40);
    return ChangeVehicleColor(vehicleid, 57, 98);
}
pawn Код:
public OnPlayerExitVehicle( playerid, vehicleid ) {
    if( var[ playerid ] == 1 ) {
        var[ playerid ] = 0;
        KillTimer( timer );
    }
    return 1;
}
Coole, I think that would not work.

EDIT: Edited the code abit.
Reply
#4

I made it with vehicleid because i think that's what he would want, it would be more difficult to use playerid because it will keep changing colors unless you have about 10 lines of code in OnPlayerExitvehicle...
Reply
#5

Quote:
Originally Posted by coole210
Посмотреть сообщение
Your changecolor function will just set all the colors at once..

Try using SetTimerEx and use this for your timer:

Код:
SetTimerEx("ChangeColor",2500,1,"i",vehicleid);
Код:
//Top of script:
#define MAX_CARS 200 //you can change this..
new dunce[MAX_CARS] = 0;
//TIMER:
public ChangeColor(vehicleid)
{
	switch(dunce(vehicleid))
  	{
		case 0: ChangeVehicleColor(vehicleid, 7, 3);dunce[vehicleid]++;
		case 1: ChangeVehicleColor(vehicleid, 5, 9);dunce[vehicleid]++;
		case 2: ChangeVehicleColor(vehicleid, 128, 7);dunce[vehicleid]++;
		case 3: ChangeVehicleColor(vehicleid, 3, 9);dunce[vehicleid]++;
		case 4: ChangeVehicleColor(vehicleid, 31, 47);dunce[vehicleid]++;
		case 5: ChangeVehicleColor(vehicleid, 78, 71);dunce[vehicleid]++;
		case 6: ChangeVehicleColor(vehicleid, 28, 45);dunce[vehicleid]++;
		case 7: ChangeVehicleColor(vehicleid, 2, 5);dunce[vehicleid]++;
		case 8: ChangeVehicleColor(vehicleid, 30, 40);dunce[vehicleid]++;
		case 9: ChangeVehicleColor(vehicleid, 57, 98);dunce[vehicleid] = 0;
	}
    return 1;
}
Untested.
Have these errors :
Код:
(2972) : error 012: invalid function call, not a valid address
(2972) : error 029: invalid expression, assumed zero
(2972) : error 029: invalid expression, assumed zero
(2972) : fatal error 107: too many error messages on one line
In line :
pawn Код:
switch(dunce(vehicleid))
Reply
#6

What i need to do with that error ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)