Esempio n. 1
0
    def __init__(self, code):
        self.code = code
        self.hash = h.Hash(code)
        self.type = 'UNKNOWN'

        # Set type.
        for vehicle_type, bool_func in Vehicle.MAPPING.items():
            if bool_func(self.hash):
                self.type = vehicle_type

        self.max_speed = Vehicle.MAX_SPEED[self.type]
Esempio n. 2
0
def spawn_ped(ped_code, ped_type, x, y, z=None):
    """
    h.Streaming.request_model MUST be called before spawning.
    """
    if z is not None:
        return h.Ped.create_ped(ped_type, h.Hash(ped_code), x, y, z, 0.0, False, False)

    ped_id = spawn_ped(ped_code, ped_type, x, y, constants.MAX_Z)

    set_ped_position(ped_id, x, y)

    return ped_id
Esempio n. 3
0
def spawn_entities(entity_codes, spawn_func):
    """
    entity_codes is a list of codes.
    """
    entity_hashes = [h.Hash(code) for code in entity_codes]

    for entity_hash in entity_hashes:
        h.Streaming.request_model(entity_hash)

    result = spawn_func()

    for entity_hash in entity_hashes:
        h.Streaming.set_model_as_no_longer_needed(entity_hash)

    return result
Esempio n. 4
0
 def __init__(self, hs):
     self.hash = h.Hash(hs)
Esempio n. 5
0
def set_ped_single_weapon(ped_id, weapon_code, infinite_ammo=False):
    h.Weapon.remove_all_ped_weapons(ped_id, 1)
    h.Weapon.give_delayed_to_ped(ped_id, h.Hash(weapon_code), 1, True)

    if infinite_ammo:
        h.Weapon.set_ped_infinite_ammo_clip(ped_id, True)