ffcmike |
09-10-2011 04:21 PM |
Quote:
Originally Posted by blackbeltben
(Post 1667702)
Im using when it triggers serverside from the attack, i tried to use SetTimer(), scheduleEvent(), Trigger, all that stuff. I dont know what the proplem is. What would you use?
|
I've explained 3 different possible methods you could use several posts previous, and I've explained the advantages/disadvantages of them where different scripters will have different ideals as to how to do it.
Neither of those 3 functions are intended from communicating between Clientside and Serverside.
To elaborate on my previous post, a triggeraction would work like this:
PHP Code:
function onCreated(){
this.setshape(1, 32, 32);
}
function onActionDamage(temp.power){
this.hp = max(0, this.hp - temp.power);
}
//#CLIENTSIDE
function onWasDmg(temp.power) {
triggeraction(this.x + 1, this.y + 1, "Damage", temp.power);
}
Whereas a basic serverside area trigger could be accomplished like this within a weapon script:
PHP Code:
function onActionServerside(temp.command, temp.x, temp.y){
switch(temp.command){
case "attack":
temp.tnpcs = findareanpcs(temp.x, temp.y, 2, 2);
for(temp.n : temp.tnpcs){
temp.n.trigger("WasDmg", player.clientr.power);
}
break;
}
}
//#CLIENTSIDE
function onAttack() {
temp.x = player.x + 0.5 + (vecx(player.dir) * 2);
temp.y = player.y + 1 + (vecy(player.dir) * 2);
triggerserver("gui", this.name, "attack", temp.x, temp.y);
}
|