Toranks
Active member
How I can change a weapon via script?
I am trying to change the model of the first available player to a specific model, and change the rest of the players to a weapon that is actually an invisible box. The problem I find is only the first player remains with the model changed, the rest stays in its original weapon, not weapon 8 as I wanted.
I don't know what step I am doing wrong, can you help me?
PD: Using
that doesn't work neither
SOLVED DEFINITIVE CODE:
I am trying to change the model of the first available player to a specific model, and change the rest of the players to a weapon that is actually an invisible box. The problem I find is only the first player remains with the model changed, the rest stays in its original weapon, not weapon 8 as I wanted.
I don't know what step I am doing wrong, can you help me?
PD: Using
Code:
changeplayerproperty(1, "weapon", 8);
Code:
name 1pryoturt
type none
nolife 1
antigravity 100
shadow 0
offscreenkill 80000
script @script
void main()
{
void self = getlocalvar("self");
char Name = getentityproperty(self,"name");
int HP = getentityproperty(self,"health");
int P1 = getplayerproperty(0, "entity");
int P2 = getplayerproperty(1, "entity");
int P3 = getplayerproperty(2, "entity");
void anim1 = getentityproperty(P1,"animationID");
void anim2 = getentityproperty(P2,"animationID");
void anim3 = getentityproperty(P3,"animationID");
changeopenborvariant("nojoin", 1);
if (P1 != NULL())
{
changeentityproperty(P1, "model", Name, 1);
changeentityproperty(P1, "defaultname", Name);
changeentityproperty(P2, "stealth", 8);
changeentityproperty(P3, "stealth", 8);
changeentityproperty(P2, "weapon", 8);
changeentityproperty(P3, "weapon", 8);
bindentity(P2, P1);
bindentity(P3, P1);
}
else if (P2 != NULL())
{
changeentityproperty(P2, "model", Name, 1);
changeentityproperty(P2, "defaultname", Name);
changeentityproperty(P3, "stealth", 8);
changeentityproperty(P3, "weapon", 8);
bindentity(P3, P2);
}
else if (P3 != NULL())
{
changeentityproperty(P3, "model", Name, 1);
changeentityproperty(P3, "defaultname", Name);
}
if (anim1 == openborconstant("ANI_SPAWN"))
{
changeentityproperty(P1, "health", HP);
}
else if (anim2 == openborconstant("ANI_SPAWN"))
{
changeentityproperty(P2, "health", HP);
}
else if (anim3 == openborconstant("ANI_SPAWN"))
{
changeentityproperty(P3, "health", HP);
}
}
@end_script
anim idle
@script
void self = getlocalvar("self");
if(frame >= 1)
{
killentity(self);
}
@end_script
loop 1
delay 3
offset 1 1
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif
SOLVED DEFINITIVE CODE:
Code:
name 1pryoturt
type none
nolife 1
antigravity 100
shadow 0
offscreenkill 80000
script @script
void main()
{
void self = getlocalvar("self");
char Name = getentityproperty(self,"name");
int HP = getentityproperty(self,"health");
int MP = getentityproperty(self,"aggression");
int P1 = getplayerproperty(0, "entity");
int P2 = getplayerproperty(1, "entity");
int P3 = getplayerproperty(2, "entity");
void anim1 = getentityproperty(P1,"animationID");
void anim2 = getentityproperty(P2,"animationID");
void anim3 = getentityproperty(P3,"animationID");
changeopenborvariant("nojoin", 1);
if (P1 != NULL() && P2 != NULL() && P3 != NULL())
{
changeentityproperty(P1, "model", Name, 1);
changeentityproperty(P1, "defaultname", Name);
changeentityproperty(P2, "stealth", 8);
changeentityproperty(P2, "model", "mrzero", 1);
changeentityproperty(P3, "stealth", 8);
changeentityproperty(P3, "model", "mrzero", 1);
bindentity(P2, P1, 0, 0, 0, 0, 0);
bindentity(P3, P1, 0, 0, 0, 0, 0);
}
else if (P1 != NULL() && P2 != NULL() && P3 == NULL())
{
changeentityproperty(P1, "model", Name, 1);
changeentityproperty(P1, "defaultname", Name);
changeentityproperty(P2, "stealth", 8);
changeentityproperty(P2, "model", "mrzero", 1);
bindentity(P2, P1, 0, 0, 0, 0, 0);
}
else if (P1 != NULL() && P2 == NULL() && P3 == NULL())
{
changeentityproperty(P1, "model", Name, 1);
changeentityproperty(P1, "defaultname", Name);
}
else if (P1 != NULL() && P2 == NULL() && P3 != NULL())
{
changeentityproperty(P1, "model", Name, 1);
changeentityproperty(P1, "defaultname", Name);
changeentityproperty(P3, "stealth", 8);
changeentityproperty(P3, "model", "mrzero", 1);
bindentity(P3, P1, 0, 0, 0, 0, 0);
}
else if (P1 == NULL() && P2 != NULL() && P3 != NULL())
{
changeentityproperty(P2, "model", Name, 1);
changeentityproperty(P2, "defaultname", Name);
changeentityproperty(P3, "stealth", 8);
changeentityproperty(P3, "model", "mrzero", 1);
bindentity(P3, P2, 0, 0, 0, 0, 0);
}
else if (P1 == NULL() && P2 != NULL() && P3 == NULL())
{
changeentityproperty(P2, "model", Name, 1);
changeentityproperty(P2, "defaultname", Name);
}
else if (P1 == NULL() && P2 == NULL() && P3 != NULL())
{
changeentityproperty(P3, "model", Name, 1);
changeentityproperty(P3, "defaultname", Name);
}
if (anim1 == openborconstant("ANI_SPAWN"))
{
changeentityproperty(P1, "health", HP);
changeentityproperty(P1, "mp", MP);
}
else if (anim2 == openborconstant("ANI_SPAWN"))
{
changeentityproperty(P2, "health", HP);
changeentityproperty(P2, "mp", MP);
}
else if (anim3 == openborconstant("ANI_SPAWN"))
{
changeentityproperty(P3, "health", HP);
changeentityproperty(P3, "mp", MP);
}
}
@end_script
anim idle
@script
void self = getlocalvar("self");
if(frame >= 1)
{
killentity(self);
}
@end_script
loop 1
delay 3
offset 1 1
frame data/chars/misc/empty.gif
frame data/chars/misc/empty.gif