What's new

Pomoc z lua!

Yoxino

Advanced User
Joined
Aug 12, 2009
Messages
478
Reaction score
51
Witam!
Mam kilka pyta? dotycz?cych skrypt?w lua (na 7.6).
1. Jak wyci?gn?? informacj? o postaci(getPlayerLevel) po klikni?ciu na n? run?.
Ja wnioskuj? ?e trzeba zrobi? tak:
player = getThingfromPos(topos)
player_lvl = getPlayerLevel(player.uid)
czy to jest dobre my?lenie?
2. Jak do powy?szego zrobi? warunek ?e wyci?gaj t? informacj? tylko jak to jest player?
 

Knes

Advanced User
Joined
Mar 5, 2010
Messages
216
Reaction score
15
Odp: Pomoc z lua!

2. W lua nie ma funkci isPlayer, trzeba by j? dodawa?..
 

Yoxino

Advanced User
Joined
Aug 12, 2009
Messages
478
Reaction score
51
Odp: Pomoc z lua!

Napisa?em funkcj? isPlayer:
Code:
int ActionScript::luaActionIsPlayer(lua_State *L)
{
    unsigned int cid = (unsigned int)internalGetNumber(L);
    ActionScript *action = getActionScript(L);
    const KnownThing* tmp = action->GetPlayerByUID(cid);
    if(tmp){
            Player *player = (Player*)(tmp->thing);
    if (player)
        lua_pushnumber(L, 1);
    else
        lua_pushnumber(L, 0);

    return 1;
            
     }
}
Kompilator nie wywala b??d?w.
Mam kod na taki specjalny parchament kt?ry teleportuje do pewnego miejsca ale tylko jak tam nie ma gracza:
Code:
function onUse(cid, item, frompos, item2, topos)
  	if doRemoveItem(item.uid,1) then
		acc_pos1 = {x=606, y=541, z=7}
		player = getThingfromPos(acc_pos1)
		if isPlayer(player.uid) then
		doTeleportThing(cid, acc_pos1)
		doPlayerSendTextMessage(cid,22,"Zostajesz przeniesiony do Account Maker'a")
		doSendMagicEffect(acc_pos1, 12)
		else
		doPlayerSendCancel(cid, "Account maker room jest teraz zajety. Prosze spr?bowac za chwile!")		
  	end
  end
end
Wywala mi crash gdy uzyje tego parchamentu. Wydaje mi si? ?e pope?ni?em b??d tu:
Code:
acc_pos1 = {x=606, y=541, z=7}
		player = getThingfromPos(acc_pos1)
		if isPlayer(player.uid) then
Prosz? o pomoc! R?wnierz do pkt 1. :)
 
Last edited:

Knes

Advanced User
Joined
Mar 5, 2010
Messages
216
Reaction score
15
Odp: Pomoc z lua!

Spr?buj tak:
Code:
acc_pos1 = {x=606, y=541, z=7, stackpos=253}

Ad.1:
Tak, jest to jest dobre my?lenie..
 
Last edited:

Yoxino

Advanced User
Joined
Aug 12, 2009
Messages
478
Reaction score
51
Odp: Pomoc z lua!

Dalej crash... mo?e co? ?le z t? funkcj???
PS: co robi to stackpos=253 ??
 

Knes

Advanced User
Joined
Mar 5, 2010
Messages
216
Reaction score
15
Odp: Pomoc z lua!

z?a funkcja -.-
b??d wida? na kilometr
 

Yoxino

Advanced User
Joined
Aug 12, 2009
Messages
478
Reaction score
51
Odp: Pomoc z lua!

Prosz? o pomoc, lub gotow? funkcj?. Z g?ry Dzi?kuj? ;)
 

Knes

Advanced User
Joined
Mar 5, 2010
Messages
216
Reaction score
15
Odp: Pomoc z lua!

PS: co robi to stackpos=253 ??
W funkcji getThingfromPos okre?la co dok?adnie chcesz "wydoby?" z tej pozycji..
Okre?la to creatures (gracze oraz potworki)



Pozdrawiam,
Baabuseek
 

Yoxino

Advanced User
Joined
Aug 12, 2009
Messages
478
Reaction score
51
Odp: Pomoc z lua!

Niestety to nie dzia?a... Nie wiem co jest nie tak. Nie wyskakuje crash ale tez nic si? nie dzieje. Mo?e zrobi? to tak jak jest zrobiony anihilator. Tam tez nie uzywana jest funkcja isPlayer. Spr?buj? i dam edita.
 

Knes

Advanced User
Joined
Mar 5, 2010
Messages
216
Reaction score
15
Odp: Pomoc z lua!

Chyba masz co? zjebane w silniku, u mnie dzia?a w 100%.
Sprawdza?em nim doda?em na forum.
 
Top