Updated instance_check_party script command (#8457)
* The command now returns 0 if the party id does not exist * Fixed #8426 Co-authored-by: Lemongrass3110 <lemongrass@kstp.at> Co-authored-by: Aleos <aleos89@users.noreply.github.com>
This commit is contained in:
parent
c8935ef18a
commit
88e3eba8cf
@ -9856,6 +9856,7 @@ For details on the other parameters, see 'announce'.
|
|||||||
|
|
||||||
This function checks if a party meets certain requirements, returning 1 if all
|
This function checks if a party meets certain requirements, returning 1 if all
|
||||||
conditions are met and 0 otherwise. It will only check online characters.
|
conditions are met and 0 otherwise. It will only check online characters.
|
||||||
|
The command returns 0 is the party ID does not exist.
|
||||||
|
|
||||||
amount - number of online party members (default is 1).
|
amount - number of online party members (default is 1).
|
||||||
min - minimum level of all characters in the party (default is 1).
|
min - minimum level of all characters in the party (default is 1).
|
||||||
|
|||||||
@ -21837,49 +21837,76 @@ BUILDIN_FUNC(instance_announce) {
|
|||||||
*------------------------------------------*/
|
*------------------------------------------*/
|
||||||
BUILDIN_FUNC(instance_check_party)
|
BUILDIN_FUNC(instance_check_party)
|
||||||
{
|
{
|
||||||
int amount, min, max, i, party_id, c = 0;
|
int32 min; // Minimum Level needed to join the Instance.
|
||||||
struct party_data *p;
|
int32 max; // Maxium Level allowed to join the Instance.
|
||||||
|
int32 amount; // Amount of needed Partymembers for the Instance.
|
||||||
|
|
||||||
amount = script_hasdata(st,3) ? script_getnum(st,3) : 1; // Amount of needed Partymembers for the Instance.
|
if (!script_hasdata(st, 3))
|
||||||
min = script_hasdata(st,4) ? script_getnum(st,4) : 1; // Minimum Level needed to join the Instance.
|
amount = 1;
|
||||||
max = script_hasdata(st,5) ? script_getnum(st,5) : MAX_LEVEL; // Maxium Level allowed to join the Instance.
|
else {
|
||||||
|
amount = script_getnum(st, 3);
|
||||||
|
|
||||||
if( min < 1 || min > MAX_LEVEL) {
|
if (amount < 1 || amount > MAX_PARTY) {
|
||||||
ShowError("buildin_instance_check_party: Invalid min level, %d\n", min);
|
ShowError("buildin_instance_check_party: Invalid amount %d. Min: 1, max: %d.\n", amount, MAX_PARTY);
|
||||||
return SCRIPT_CMD_FAILURE;
|
st->state = END;
|
||||||
} else if( max < 1 || max > MAX_LEVEL) {
|
|
||||||
ShowError("buildin_instance_check_party: Invalid max level, %d\n", max);
|
|
||||||
return SCRIPT_CMD_FAILURE;
|
return SCRIPT_CMD_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( script_hasdata(st,2) )
|
|
||||||
party_id = script_getnum(st,2);
|
|
||||||
else return SCRIPT_CMD_FAILURE;
|
|
||||||
|
|
||||||
if( !(p = party_search(party_id)) ) {
|
|
||||||
script_pushint(st, 0); // Returns false if party does not exist.
|
|
||||||
return SCRIPT_CMD_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for( i = 0; i < MAX_PARTY; i++ ) {
|
if (!script_hasdata(st, 4))
|
||||||
map_session_data *pl_sd;
|
min = 1;
|
||||||
if( (pl_sd = p->data[i].sd) )
|
else {
|
||||||
if(map_id2bl(pl_sd->bl.id) && !pl_sd->state.autotrade) {
|
min = script_getnum(st, 4);
|
||||||
if(pl_sd->status.base_level < min) {
|
|
||||||
script_pushint(st, 0);
|
if (min < 1 || min > MAX_LEVEL) {
|
||||||
return SCRIPT_CMD_SUCCESS;
|
ShowError("buildin_instance_check_party: Invalid min level %d. Min: 1, max: %d.\n", min, MAX_LEVEL);
|
||||||
} else if(pl_sd->status.base_level > max) {
|
st->state = END;
|
||||||
|
return SCRIPT_CMD_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!script_hasdata(st, 5))
|
||||||
|
max = MAX_LEVEL;
|
||||||
|
else {
|
||||||
|
max = script_getnum(st, 5);
|
||||||
|
|
||||||
|
if (max < 1 || max > MAX_LEVEL) {
|
||||||
|
ShowError("buildin_instance_check_party: Invalid max level %d. Min: 1, max: %d.\n", max, MAX_LEVEL);
|
||||||
|
st->state = END;
|
||||||
|
return SCRIPT_CMD_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 party_id = script_getnum(st, 2);
|
||||||
|
party_data *p = party_search( party_id );
|
||||||
|
|
||||||
|
if (p == nullptr) {
|
||||||
script_pushint(st, 0);
|
script_pushint(st, 0);
|
||||||
return SCRIPT_CMD_SUCCESS;
|
return SCRIPT_CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
c++;
|
|
||||||
}
|
int32 count = 0;
|
||||||
|
|
||||||
|
for( size_t i = 0; i < MAX_PARTY; i++ ) {
|
||||||
|
map_session_data *sd = p->data[i].sd;
|
||||||
|
|
||||||
|
if (sd == nullptr){
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(c < amount)
|
if (sd->state.autotrade) {
|
||||||
script_pushint(st, 0); // Not enough Members in the Party to join Instance.
|
continue;
|
||||||
else
|
}
|
||||||
script_pushint(st, 1);
|
|
||||||
|
if (sd->status.base_level < min || sd->status.base_level > max) {
|
||||||
|
script_pushint(st, 0);
|
||||||
|
return SCRIPT_CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
script_pushint(st, count >= amount);
|
||||||
|
|
||||||
return SCRIPT_CMD_SUCCESS;
|
return SCRIPT_CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user