їLo estoy haciendo bien?
#1

Buenas, estoy haciendo una funciуn para comprobar la ID del camiуn, pero no sй si la estoy haciendo bien.
PHP код:
public OnGameModeInit()
{
    
vehcam[0] = CreateVehicle(4141052.85511917.724710.89810.0000, -1, -1100);
    
vehcam[1] = CreateVehicle(4141060.37571917.955710.89810.0000, -1, -1100);
    
vehcam[2] = CreateVehicle(4141067.82541917.862710.89810.0000, -1, -1100);
    
vehcam[3] = CreateVehicle(4141076.50061917.822510.89810.0000, -1, -1100);
    
vehcam[4] = CreateVehicle(4141082.67081917.772110.89810.0000, -1, -1100);
    
vehcam[5] = CreateVehicle(4141091.25501917.810710.89810.0000, -1, -1100);
    
vehcam[6] = CreateVehicle(4141106.04961920.002810.898190.0000, -1, -1100);
    
vehcam[7] = CreateVehicle(4141106.00441925.888710.898190.0000, -1, -1100);
    
vehcam[8] = CreateVehicle(4141106.01721934.774010.898190.0000, -1, -1100);
    
vehcam[9] = CreateVehicle(4141106.05161911.257210.898190.0000, -1, -1100);
    
vehcam[10] = CreateVehicle(4141106.15341903.856410.898190.0000, -1, -1100);
    
vehcam[11] = CreateVehicle(4141106.12991896.611310.898190.0000, -1, -1100);
    
vehcam[12] = CreateVehicle(4141091.72191889.232910.8981180.0000, -1, -1100);
    
vehcam[13] = CreateVehicle(4141082.83151889.224010.8981180.0000, -1, -1100);
    
vehcam[14] = CreateVehicle(4141076.63241889.321710.8981180.0000, -1, -1100);
    for(new 
iMAX_CAMIONESi++)
    {
        
InformacionCam[i][CAM_ID] = vehcam[i];
    }
    return 
1;
}
stock GetCamionID(vehicleid)
{
    for(new 
iMAX_CAMIONESi++)
    {
        if(
InformacionCam[i][CAM_ID] != vehicleid)
            continue;
            
        return 
i;
    }
    return -
1;

Desde ya muchas gracias.
Reply
#2

PHP код:
stock GetCamionID(vehicleid){
    new 
id;
    for(new 
xx=0xxx<MAX_CAMIONESxx<=xxxxx++){{
        if(
InformacionCam[xx][CAM_ID] == vehicleidid xx;
        else 
id = -1;
    }
    return 
id;

Reply
#3

Vas bien, pero hay algunos notas. No es necesario hacer un loop para asignar una variable como el ID de un vehнculo y cuando vayas a retornar un valor en un loop, parra el loop primero con "break;", y luego retorna el valor.

pawn Код:
new vhTruckCount;

public OnGameModeInit()
{
    CreateTruck(414, 1052.8551, 1917.7247, 10.8981, 0.0000, -1, -1, 100);
    CreateTruck(414, 1060.3757, 1917.9557, 10.8981, 0.0000, -1, -1, 100);
    CreateTruck(414, 1067.8254, 1917.8627, 10.8981, 0.0000, -1, -1, 100);
    CreateTruck(414, 1076.5006, 1917.8225, 10.8981, 0.0000, -1, -1, 100);
    CreateTruck(414, 1082.6708, 1917.7721, 10.8981, 0.0000, -1, -1, 100);
    CreateTruck(414, 1091.2550, 1917.8107, 10.8981, 0.0000, -1, -1, 100);
    CreateTruck(414, 1106.0496, 1920.0028, 10.8981, 90.0000, -1, -1, 100);
    CreateTruck(414, 1106.0044, 1925.8887, 10.8981, 90.0000, -1, -1, 100);
    CreateTruck(414, 1106.0172, 1934.7740, 10.8981, 90.0000, -1, -1, 100);
    CreateTruck(414, 1106.0516, 1911.2572, 10.8981, 90.0000, -1, -1, 100);
    CreateTruck(414, 1106.1534, 1903.8564, 10.8981, 90.0000, -1, -1, 100);
    CreateTruck(414, 1106.1299, 1896.6113, 10.8981, 90.0000, -1, -1, 100);
    CreateTruck(414, 1091.7219, 1889.2329, 10.8981, 180.0000, -1, -1, 100);
    CreateTruck(414, 1082.8315, 1889.2240, 10.8981, 180.0000, -1, -1, 100);
    CreateTruck(414, 1076.6324, 1889.3217, 10.8981, 180.0000, -1, -1, 100);
    return 1;
}

stock CreateTruck(model, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay, addsiren = 0)
{
    InformacionCam[vhTruckCount][CAM_ID] = CreateVehicle(model, x, y, z, angle, color1, color2, respawn_delay, addsiren);
    vhTruckCount ++;
}

stock GetTruckID(vehicleid)
{
    new truckid = -1;
    for(new i = 0; i < MAX_CAMIONES; i ++)
    {
        if(InformacionCam[i][CAM_ID] == vehicleid)
        {
            truckid = i;
            break;
        }
    }
    return truckid;
}
Y ese nombre en Spanglish, que onda?
Reply
#4

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Vas bien, pero hay algunos notas. No es necesario hacer un loop para asignar una variable como el ID de un vehнculo y cuando vayas a retornar un valor en un loop, parra el loop primero con "break;", y luego retorna el valor.

pawn Код:
new vhTruckCount;

public OnGameModeInit()
{
    CreateTruck(414, 1052.8551, 1917.7247, 10.8981, 0.0000, -1, -1, 100);
    CreateTruck(414, 1060.3757, 1917.9557, 10.8981, 0.0000, -1, -1, 100);
    CreateTruck(414, 1067.8254, 1917.8627, 10.8981, 0.0000, -1, -1, 100);
    CreateTruck(414, 1076.5006, 1917.8225, 10.8981, 0.0000, -1, -1, 100);
    CreateTruck(414, 1082.6708, 1917.7721, 10.8981, 0.0000, -1, -1, 100);
    CreateTruck(414, 1091.2550, 1917.8107, 10.8981, 0.0000, -1, -1, 100);
    CreateTruck(414, 1106.0496, 1920.0028, 10.8981, 90.0000, -1, -1, 100);
    CreateTruck(414, 1106.0044, 1925.8887, 10.8981, 90.0000, -1, -1, 100);
    CreateTruck(414, 1106.0172, 1934.7740, 10.8981, 90.0000, -1, -1, 100);
    CreateTruck(414, 1106.0516, 1911.2572, 10.8981, 90.0000, -1, -1, 100);
    CreateTruck(414, 1106.1534, 1903.8564, 10.8981, 90.0000, -1, -1, 100);
    CreateTruck(414, 1106.1299, 1896.6113, 10.8981, 90.0000, -1, -1, 100);
    CreateTruck(414, 1091.7219, 1889.2329, 10.8981, 180.0000, -1, -1, 100);
    CreateTruck(414, 1082.8315, 1889.2240, 10.8981, 180.0000, -1, -1, 100);
    CreateTruck(414, 1076.6324, 1889.3217, 10.8981, 180.0000, -1, -1, 100);
    return 1;
}

stock CreateTruck(model, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay, addsiren = 0)
{
    InformacionCam[vhTruckCount][CAM_ID] = CreateVehicle(model, x, y, z, angle, color1, color2, respawn_delay, addsiren);
    vhTruckCount ++;
}

stock GetTruckID(vehicleid)
{
    new truckid = -1;
    for(new i = 0; i < MAX_CAMIONES; i ++)
    {
        if(InformacionCam[i][CAM_ID] == vehicleid)
        {
            truckid = i;
            break;
        }
    }
    return truckid;
}
Y ese nombre en Spanglish, que onda?
Perfect! :3 Gracias.
Tengo la costumbre de hacer las funciones Spanglish xDDD


---------------

їMe pueden ayudar con esto por favor? :C
Nuevamente, muchas gracias.
PHP код:
if(GetTruckID(veh) == -1) return MensajeError(playerid, -1"No estas en un vehнculo del trabajo."); 
Quote:

C:\Users\Equipo\PosibleRP\gamemodes\Gamemode.pwn(9 19) : error 001: expected token: "-string end-", but found "-identifier-"

Reply
#5

pawn Код:
if(GetTruckID(veh) == -1) return SendClientMessage(playerid, -1, "No estas en un vehнculo del trabajo.");
Reply
#6

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
pawn Код:
if(GetTruckID(veh) == -1) return SendClientMessage(playerid, -1, "No estas en un vehнculo del trabajo.");
Pero yo ya tengo esto:
pawn Код:
#define MensajeError(%0,%1) SendClientMessage(%0,-1,"{FF0000}[ERROR]:{FFFFFF} "%1)
Reply
#7

Quote:
Originally Posted by Ghost112397
Посмотреть сообщение
Pero yo ya tengo esto:
pawn Код:
#define MensajeError(%0,%1) SendClientMessage(%0,-1,"{FF0000}[ERROR]:{FFFFFF} "%1)
Estas seguro que es ese linea que te da el error?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)