Problema cargando Paintjob y Colores de vehнculos
#1

Hola, mi problema es este:

pawn Код:
public OnVehicleSpawn(vehicleid)
{
    SetVehicleZAngle(vehicleid, VehiculosInfo[vehicleid][PosA]);
    SetVehiclePos(vehicleid, VehiculosInfo[vehicleid][PosX], VehiculosInfo[vehicleid][PosY], VehiculosInfo[vehicleid][PosZ]);
/**/if(VehiculosInfo[vehicleid][Paintjob] > -1) ChangeVehiclePaintjob(vehicleid, VehiculosInfo[vehicleid][Paintjob]);
    if(VehiculosInfo[vehicleid][mod1] != 0) AddVehicleComponent(vehicleid,VehiculosInfo[vehicleid][mod1]);
    if(VehiculosInfo[vehicleid][mod2] != 0) AddVehicleComponent(vehicleid,VehiculosInfo[vehicleid][mod2]);
    if(VehiculosInfo[vehicleid][mod3] != 0) AddVehicleComponent(vehicleid,VehiculosInfo[vehicleid][mod3]);
    if(VehiculosInfo[vehicleid][mod4] != 0) AddVehicleComponent(vehicleid,VehiculosInfo[vehicleid][mod4]);
    if(VehiculosInfo[vehicleid][mod5] != 0) AddVehicleComponent(vehicleid,VehiculosInfo[vehicleid][mod5]);
    if(VehiculosInfo[vehicleid][mod6] != 0) AddVehicleComponent(vehicleid,VehiculosInfo[vehicleid][mod6]);
    if(VehiculosInfo[vehicleid][mod7] != 0) AddVehicleComponent(vehicleid,VehiculosInfo[vehicleid][mod7]);
    if(VehiculosInfo[vehicleid][mod8] != 0) AddVehicleComponent(vehicleid,VehiculosInfo[vehicleid][mod8]);
    if(VehiculosInfo[vehicleid][mod9] != 0) AddVehicleComponent(vehicleid,VehiculosInfo[vehicleid][mod9]);
    if(VehiculosInfo[vehicleid][mod10] != 0) AddVehicleComponent(vehicleid,VehiculosInfo[vehicleid][mod10]);
    if(VehiculosInfo[vehicleid][mod11] != 0) AddVehicleComponent(vehicleid,VehiculosInfo[vehicleid][mod11]);
    if(VehiculosInfo[vehicleid][mod12] != 0) AddVehicleComponent(vehicleid,VehiculosInfo[vehicleid][mod12]);
    if(VehiculosInfo[vehicleid][mod13] != 0) AddVehicleComponent(vehicleid,VehiculosInfo[vehicleid][mod13]);
    if(VehiculosInfo[vehicleid][mod14] != 0) AddVehicleComponent(vehicleid,VehiculosInfo[vehicleid][mod14]);
    if(VehiculosInfo[vehicleid][mod15] != 0) AddVehicleComponent(vehicleid,VehiculosInfo[vehicleid][mod15]);
    if(VehiculosInfo[vehicleid][mod16] != 0) AddVehicleComponent(vehicleid,VehiculosInfo[vehicleid][mod16]);
    if(VehiculosInfo[vehicleid][mod17] != 0) AddVehicleComponent(vehicleid,VehiculosInfo[vehicleid][mod17]);
/**/ChangeVehicleColor(vehicleid, VehiculosInfo[vehicleid][Color1], VehiculosInfo[vehicleid][Color2]);
    return 1;
}
Como pueden ver cargo todo el tuning de los vehнculos cuando el mismo spawnea, y a su vez cargo el color y el paintjob del auto.
Carga todo bien, pero si el auto tuneado tiene un paintjob (por ejemplo id 2) y encima un color, me refiero a que estб el paintjob + 1 color encima, solo carga el paintjob y el color queda por debajo.

No se si me entiendan pero estoy hace horas intentando arreglar esto, y no logro entender porque no funciona porque en el script primero seteo el paintjob y luego el color, pero sin embargo el color se setea primero que el paintjob :S.

Estarнa muy agradecido si alguien me explicara que es lo que estoy haciendo mal o si alguien sabe como resolverlo, desde ya muchas gracias,
Miller
Reply
#2

debes cargar primero el Paintjob y despues el color.


http://pastebin.com/ykAAzMmS
http://pastebin.com/UDywPBpH
Reply
#3

Quote:
Originally Posted by OTACON
Посмотреть сообщение
debes cargar primero el Paintjob y despues el color.


http://pastebin.com/ykAAzMmS
http://pastebin.com/UDywPBpH
Pero es lo que hago, creo yo:

pawn Код:
public OnVehicleSpawn(vehicleid)
{
    if(VehiculosInfo[vehicleid][Paintjob] > -1) ChangeVehiclePaintjob(vehicleid, VehiculosInfo[vehicleid][Paintjob]);
    ChangeVehicleColor(vehicleid, VehiculosInfo[vehicleid][Color1], VehiculosInfo[vehicleid][Color2]);
}
Es como si el ChangeVehicleColor necesitara un "delay" :S
Reply
#4

ah puede ser, ya que creo que OnVehicleSpawn es llamado cuando el vehiculo spawnea no creado, osea cuando inicias el gm son creados y no es llamado el call OnVehicleSpawn , es llamado cuando es respawneado con la funcion,destruido por explosion, respawneado con el parametro delay de la funcion que lo crea.

este test funciona perfecto .

pawn Код:
//TESTING...
#include <a_samp>
#include <zcmd> //https://sampforum.blast.hk/showthread.php?tid=91354
#include <sscanf2> //https://sampforum.blast.hk/showthread.php?tid=120356

//FUNCTION...
new PaintjobVehicle[MAX_VEHICLES],bool:PaintjobActivated[MAX_VEHICLES];
#define GetVehiclePaintjob(%0) PaintjobActivated[%0]
#define GetVehiclePaintjobType(%0) PaintjobVehicle[%0]
stock ChangeVehiclePaintjobEx(vehicleid, paintjobid){
PaintjobVehicle[vehicleid] = paintjobid;
PaintjobActivated[vehicleid] = true;
return ChangeVehiclePaintjob(vehicleid, paintjobid); }
#define ChangeVehiclePaintjob ChangeVehiclePaintjobEx
#define RemoveVehiclePaintjob(%0) PaintjobActivated[%0]=false, ChangeVehiclePaintjob(%0, 3)
/*
    native ChangeVehiclePaintjob(vehicleid, paintjobid); //para colocar el paintjob al vehiculo correspondiente (es el del por defecto de SA-MP).
    native RemoveVehiclePaintjob(vehicleid); //para remover el paintjob del vehiculo correspondiente.
    native GetVehiclePaintjob(vehicleid); //para verificar si el vehiculo correspondiente tiene un paintjob colocado.
    native GetVehiclePaintjobType(vehicleid); //para verificar el tipo de paintjob colocado en el vehiculo correspondiente.
*/


//FUNCTION...
new ColorVehicle[2][MAX_VEHICLES];
#define GetVehicleColor1(%0) ColorVehicle[0][%0]
#define GetVehicleColor2(%0) ColorVehicle[1][%0]
stock ChangeVehicleColorEx(vehicleid, color1, color2){
ColorVehicle[0][vehicleid] = color1;
ColorVehicle[1][vehicleid] = color2;
return ChangeVehicleColor(vehicleid, color1, color2); }
#define ChangeVehicleColor ChangeVehicleColorEx
/*
    native ChangeVehicleColor(vehicleid, color1, color2); //el del por defecto de SA-MP
    native GetVehicleColor1(vehicleid); //para verificar e guardar el color 1 que tiene el vehiculo
    native GetVehicleColor2(vehicleid); //para verificar e guardar el color 2 que tiene el vehiculo
*/


public OnVehicleSpawn(vehicleid){
    if(GetVehiclePaintjob(vehicleid)){ //si tiene paintjob
        ChangeVehiclePaintjob(vehicleid, GetVehiclePaintjobType(vehicleid));
        ChangeVehicleColor(vehicleid, GetVehicleColor1(vehicleid), GetVehicleColor2(vehicleid));
    }else{ //no tiene paintjob
        RemoveVehiclePaintjob(vehicleid);
        ChangeVehicleColor(vehicleid, GetVehicleColor1(vehicleid), GetVehicleColor2(vehicleid));
    }
    return true;
}

COMMAND:colorveh(playerid, params[]){
    new vehicleid = GetPlayerVehicleID(playerid), data[128];
    if(sscanf(params, "dd", params[0], params[1])) return SendClientMessage(playerid, -1, "Escribe: /colorveh [color1] [color2]");
    format(data,sizeof(data),"Color Anterior en Variable: [color1:%d - color2:%d]",GetVehicleColor1(vehicleid),GetVehicleColor2(vehicleid));
    SendClientMessage(playerid,-1,data);
    ChangeVehicleColor(vehicleid, params[0], params[1]);
    format(data,sizeof(data),"Color Colocado: [color1:%d - color2:%d] - Color guardado en Variable: [color1:%d - color2:%d]",params[0], params[1], GetVehicleColor1(vehicleid),GetVehicleColor2(vehicleid));
    SendClientMessage(playerid,-1,data);
    return true;
}

COMMAND:paintjobveh(playerid, params[]){
    new vehicleid = GetPlayerVehicleID(playerid), data[128];
    if(sscanf(params, "d", params[0])) return SendClientMessage(playerid, -1, "Escribe: /paintjobveh [paintjob]");
    format(data,sizeof(data),"tipo de paintjob Anterior en Variable: [paintjob:%d] - paintjob modo[%b]", GetVehiclePaintjobType(vehicleid), GetVehiclePaintjob(vehicleid));
    SendClientMessage(playerid,-1,data);
    ChangeVehiclePaintjob(vehicleid, params[0]);
    format(data,sizeof(data),"tipo de paintjob Colocado: [paintjob:%d] - tipo de paintjob guardado en Variable: [paintjob:%d] - paintjob activado[%b]",params[0], GetVehiclePaintjobType(vehicleid), GetVehiclePaintjob(vehicleid));
    SendClientMessage(playerid,-1,data);
    return true;
}
COMMAND:paintjobremove(playerid, params[]){
    new vehicleid = GetPlayerVehicleID(playerid), data[128];
    format(data,sizeof(data),"removiste el [paintjob:%d] al vehiculo [vehicleid:%d]",GetVehiclePaintjob(vehicleid), vehicleid);
    SendClientMessage(playerid,-1,data);
    RemoveVehiclePaintjob(vehicleid);
    format(data,sizeof(data),"el vehiculo: [vehicleid:%d] tiene el paintjob: [paintjob:%d]",vehicleid, GetVehiclePaintjob(vehicleid));
    SendClientMessage(playerid,-1,data);
    return true;
}
COMMAND:paintjobactivated(playerid, params[]){
    new vehicleid = GetPlayerVehicleID(playerid), data[128];
    format(data,sizeof(data),"el vehiculo [vehicleid:%d] tiene el paintjob: [modo:%b]",vehicleid, GetVehiclePaintjobType(vehicleid));
    SendClientMessage(playerid,-1,data);
    return true;
}

COMMAND:respawn(playerid, params[]){
    new vehicleid = GetPlayerVehicleID(playerid), data[128];
    format(data,sizeof(data),"el vehiculo [vehicleid:%d] ha sido respawneado correctamente",vehicleid);
    SendClientMessage(playerid,-1,data);
    format(data,sizeof(data),"el vehiculo [vehicleid:%d] tiene el paintjob: [paintjob:%d] color del vehiculo [color1:%d color2:%d]",vehicleid, GetVehiclePaintjobType(vehicleid),GetVehicleColor1(vehicleid),GetVehicleColor2(vehicleid));
    SendClientMessage(playerid,-1,data);
    SetVehicleToRespawn(vehicleid);
    return true;
}
Reply
#5

Gracias Otacon, pero no se como se arreglo sуlo o.O
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)