žaidėjo id

Šiame forume rašomi vartotojų klausimai/problemos su kuriomis jie susidūrė kuriant pluginus.
Post Reply
User avatar
aurimasko
Flooderis arba specialistas
Posts: 736
Joined: 2010 Sep 04 08:45

žaidėjo id

Post by aurimasko »

Kai sužinoti žaidėjo ID kuris paleido raketą? ir kaip sužinoti ar tas žaidėjas į kurį pataikė raketa jau negyvas?

Code: Select all

 public rocket_touch(id, world){    new Float:location[3]    new players[32]    new playercount    entity_get_vector(id,EV_VEC_origin,location)    emit_sound(id, CHAN_WEAPON, _RpgSounds[2], 0.0, 0.0, SND_STOP, PITCH_NORM)      explode(location, SpriteExplosion, 30, 10, 0)     get_players(players,playercount,"a")     for (new i=0; i<playercount; i++)    {        new Float:playerlocation[3]        new Float:resultdistance            pev(players[i], pev_origin, playerlocation)                resultdistance = get_distance_f(playerlocation,location)            if(resultdistance < 450.0)        {            fakedamage(players[i],"RPG",(1000.0 - (2.0*resultdistance)),DMG_BLAST)        }    }    emit_sound(id, CHAN_AUTO, _RpgSounds[1], 1.0, ATTN_NORM, 0, PITCH_NORM)    remove_entity(id)        return PLUGIN_CONTINUE  }  

newb
Pluginų patvirtintojas
Posts: 1047
Joined: 2010 Sep 23 21:43
Location: Wonderland
Contact:

Re: žaidėjo id

Post by newb »

Po fakedamage tikrink ar players gyvas. O kas paleido, is cia tikriausei nesuzinosi.

User avatar
aurimasko
Flooderis arba specialistas
Posts: 736
Joined: 2010 Sep 04 08:45

Re: žaidėjo id

Post by aurimasko »

o iš šito kodo?

Code: Select all

 public rpg_pre(weapon){    if (!is_valid_ent(weapon)) return PLUGIN_CONTINUE    new id = entity_get_edict( weapon, EV_ENT_owner )     new  ent    new Float:where[3]    new gmsgShake = get_user_msgid("ScreenShake")     message_begin(MSG_ONE, gmsgShake, {0,0,0}, id)    write_short(255<< 14 ) //ammount     write_short(1 << 14) //lasts this long     write_short(255<< 14) //frequency       message_end()      ent = create_entity("info_target")    set_pev(ent, pev_classname, "rpg_missile")    set_pev(ent, pev_solid, SOLID_TRIGGER)    set_pev(ent, pev_movetype, MOVETYPE_BOUNCE)    entity_set_model(ent, "models/rpgrocket.mdl")    pev(id, pev_origin, where)    where[2] += 50.0;    where[0] += random_float(-20.0, 20.0)    where[1] += random_float(-20.0, 20.0)    entity_set_origin(ent, where)    entity_get_vector(id,EV_VEC_angles,where)    //where[1] = random_float(0.0, 180.0)    entity_set_vector(ent, EV_VEC_angles, where)    velocity_by_aim(id, 700, where)    //entity_set_edict(ent, EV_ENT_aiment, id );    //where[2] += 200.0;    entity_set_edict(ent,EV_ENT_owner,id)    entity_set_vector(ent,EV_VEC_velocity,where)    message_begin( MSG_BROADCAST, SVC_TEMPENTITY )    write_byte( TE_BEAMFOLLOW )    write_short(ent) // entity    write_short(m_iTrail)  // model    write_byte( 10 )       // lifeffffff        write_byte( 8 )        // width     write_byte( 130)      // r, g, b    write_byte( 130 )    // r, g, b    write_byte( 130 )      // r, g, b    write_byte( 196 )    // brightness    message_end()    emit_sound(id, CHAN_WEAPON, _RpgSounds[0], 1.0, ATTN_NORM, 0, PITCH_NORM)    emit_sound(ent, CHAN_WEAPON, _RpgSounds[2], 1.0, ATTN_NORM, 0, PITCH_NORM)     RegisterHamFromEntity(Ham_Think,ent,"fw_rocket_think")    set_pev(ent, pev_nextthink, get_gametime()+0.25);     set_pdata_float( weapon , 46 , 2.5, 4 );    set_user_weaponanim(id, 2)     //cs_set_weapon_ammo(gun, 2000)    return HAM_SUPERCEDE}public fw_rocket_think(ent){    entity_set_float(ent, EV_FL_nextthink, get_gametime() + 0.25)     new id = entity_get_edict( ent, EV_ENT_owner )    new Float:where[3]    entity_get_vector(id,EV_VEC_angles,where)    entity_set_vector(ent, EV_VEC_angles, where)    velocity_by_aim(id, 700, where)        entity_set_vector(ent,EV_VEC_velocity,where)     return PLUGIN_CONTINUE}

User avatar
hleV
AMX Mod X ekspertai
Posts: 875
Joined: 2011 Apr 02 11:23
Skype: hlev.lt
Location: Šiauliai

Re: žaidėjo id

Post by hleV »

entity_get_edict(ent, EV_ENT_owner) grąžina paleidėjo ID. ent tavo atveju yra id rocket_touch() funkcijoje, bet galėtum pervadint į ent.
Image ← RIP best userbar
DISKUSIJA: KIETAS PLUGIN'O UŽSAKOVAS
Privačios pagalbos neteikiu!

User avatar
aurimasko
Flooderis arba specialistas
Posts: 736
Joined: 2010 Sep 04 08:45

Re: žaidėjo id

Post by aurimasko »

error:

Code: Select all

L 05/03/2011 - 16:05:48: [FUN] Player out of range (145)L 05/03/2011 - 16:05:48: [AMXX] Displaying debug trace (plugin "jailbreak_last_request.amxx")L 05/03/2011 - 16:05:48: [AMXX] Run time error 10: native error (native "set_user_frags")L 05/03/2011 - 16:05:48: [AMXX]    [0] jailbreak_last_request.sma::rocket_touch (line 261) 
eilutė:

Code: Select all

public rocket_touch(id, world){    new Float:location[3]    new players[32]    new playercount    entity_get_vector(id,EV_VEC_origin,location)    entity_get_edict(id, EV_ENT_owner)    new ent = id     emit_sound(id, CHAN_WEAPON, _RpgSounds[2], 0.0, 0.0, SND_STOP, PITCH_NORM)      explode(location, SpriteExplosion, 30, 10, 0)     get_players(players,playercount,"a")     for (new i=0; i<playercount; i++)    {        new Float:playerlocation[3]        new Float:resultdistance            pev(players[i], pev_origin, playerlocation)                resultdistance = get_distance_f(playerlocation,location)            if(resultdistance < 450.0)        {            fakedamage(players[i],"RPG",(1000.0 - (2.0*resultdistance)),DMG_BLAST)                        if(!is_user_alive(players[i]))            {                set_user_frags(ent, get_user_frags(ent) + 1 ) // čia meta                user_silentkill(players[i] )                    make_deathmsg( ent, players[i], 0, "grenade" )                 SetHamParamInteger(3, 2)            }        }    }    emit_sound(id, CHAN_AUTO, _RpgSounds[1], 1.0, ATTN_NORM, 0, PITCH_NORM)    remove_entity(id)        return PLUGIN_CONTINUE  } 

newb
Pluginų patvirtintojas
Posts: 1047
Joined: 2010 Sep 23 21:43
Location: Wonderland
Contact:

Re: žaidėjo id

Post by newb »

Code: Select all

public rocket_touch(ent, world){    new Float:location[3]    new players[32]    new playercount    entity_get_vector(id,EV_VEC_origin,location)    new id = entity_get_edict(ent, EV_ENT_owner)     emit_sound(ent, CHAN_WEAPON, _RpgSounds[2], 0.0, 0.0, SND_STOP, PITCH_NORM)     explode(location, SpriteExplosion, 30, 10, 0)     get_players(players,playercount,"a")     for (new i=0; i<playercount; i++)    {        new Float:playerlocation[3]        new Float:resultdistance           pev(players[i], pev_origin, playerlocation)               resultdistance = get_distance_f(playerlocation,location)           if(resultdistance < 450.0)        {            fakedamage(players[i],"RPG",(1000.0 - (2.0*resultdistance)),DMG_BLAST)                       if(!is_user_alive(players[i]))            {                set_user_frags(id, get_user_frags(id) + 1)                user_silentkill(players[i])                make_deathmsg( id, players[i], 0, "grenade" )                SetHamParamInteger(3, 2)            }        }    }    emit_sound(ent, CHAN_AUTO, _RpgSounds[1], 1.0, ATTN_NORM, 0, PITCH_NORM)    remove_entity(ent)       return PLUGIN_CONTINUE }
Bet seip nesuprantu kam tu darai user_silentkill gi fakedamage turi zudyt ir apskaicuoja pagal atstuma dmg, o tu dabar zudai iskart nesvabu kiek hp nuima.

User avatar
aurimasko
Flooderis arba specialistas
Posts: 736
Joined: 2010 Sep 04 08:45

Re: žaidėjo id

Post by aurimasko »

newb wrote:

Code: Select all

public rocket_touch(ent, world){    new Float:location[3]    new players[32]    new playercount    entity_get_vector(id,EV_VEC_origin,location)    new id = entity_get_edict(ent, EV_ENT_owner)     emit_sound(ent, CHAN_WEAPON, _RpgSounds[2], 0.0, 0.0, SND_STOP, PITCH_NORM)     explode(location, SpriteExplosion, 30, 10, 0)     get_players(players,playercount,"a")     for (new i=0; i<playercount; i++)    {        new Float:playerlocation[3]        new Float:resultdistance           pev(players[i], pev_origin, playerlocation)               resultdistance = get_distance_f(playerlocation,location)           if(resultdistance < 450.0)        {            fakedamage(players[i],"RPG",(1000.0 - (2.0*resultdistance)),DMG_BLAST)                       if(!is_user_alive(players[i]))            {                set_user_frags(id, get_user_frags(id) + 1)                user_silentkill(players[i])                make_deathmsg( id, players[i], 0, "grenade" )                SetHamParamInteger(3, 2)            }        }    }    emit_sound(ent, CHAN_AUTO, _RpgSounds[1], 1.0, ATTN_NORM, 0, PITCH_NORM)    remove_entity(ent)       return PLUGIN_CONTINUE }
Bet seip nesuprantu kam tu darai user_silentkill gi fakedamage turi zudyt ir apskaicuoja pagal atstuma dmg, o tu dabar zudai iskart nesvabu kiek hp nuima.
Tiksliai! :D

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests