Expand 'checkvending' script
* Added returned values for buying store. * Made returned values as bitmask. &1 - Vending, &2 - Autotrading, &4 - Buyingstore Signed-off-by: Cydh Ramdh <house.bad@gmail.com>
This commit is contained in:
parent
0fd7ba72df
commit
bbe733e236
@ -3567,24 +3567,35 @@ warg and 0 if they don't.
|
|||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
*checkvending({"<Player Name>"})
|
*checkvending({"<Player Name>"})
|
||||||
*checkchatting({"<Player Name>"})
|
|
||||||
|
|
||||||
Checks if the player is vending or in a chatroom.
|
Checks if the player is vending or has buyingstore.
|
||||||
Name is optional, and defaults to the attached player if omitted.
|
Name is optional, and defaults to the attached player if omitted.
|
||||||
|
|
||||||
Return values for 'checkvending' are
|
The returned values are bitmask of.
|
||||||
0 = not vending
|
0 = not vending, doesn't have buyingstore, & not autotrading
|
||||||
1 = normal vending
|
1 = normal vending
|
||||||
2 = vending using @autotrade
|
2 = using @autotrade
|
||||||
|
4 = has buyingstore
|
||||||
'checkchatting' returns 1 if they are in a chat room, 0 if they are not.
|
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
//This will check if Aaron is vending, and if so, put a message in front
|
//This will check if Aaron's state
|
||||||
//of the attached player saying Aaron is vending.
|
.@state = checkvending("Aaron");
|
||||||
if (checkvending("Aaron"))
|
if (.@state&1)
|
||||||
mes "Aaron is currently vending!";
|
mes "Aaron is currently vending!";
|
||||||
|
if (.@state&2)
|
||||||
|
mes "Aaron is autotrading!";
|
||||||
|
if (.@state&4)
|
||||||
|
mes "Aaron has buying store!";
|
||||||
|
|
||||||
|
---------------------------------------
|
||||||
|
|
||||||
|
*checkchatting({"<Player Name>"})
|
||||||
|
|
||||||
|
Checks if the player is in a chatroom.
|
||||||
|
Name is optional, and defaults to the attached player if omitted.
|
||||||
|
Returns 1 if they are in a chat room, 0 if they are not.
|
||||||
|
|
||||||
|
Examples:
|
||||||
//This will check if the attached player in a chat room or not.
|
//This will check if the attached player in a chat room or not.
|
||||||
if (checkchatting())
|
if (checkchatting())
|
||||||
mes "You are currently in a chat room!";
|
mes "You are currently in a chat room!";
|
||||||
|
@ -15929,21 +15929,39 @@ BUILDIN_FUNC(getmonsterinfo)
|
|||||||
return SCRIPT_CMD_SUCCESS;
|
return SCRIPT_CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
BUILDIN_FUNC(checkvending) // check vending [Nab4]
|
/**
|
||||||
{
|
* Check player's vending/buyingstore/autotrade state
|
||||||
|
* checkvending({"<Player Name>"})
|
||||||
|
* @author [Nab4]
|
||||||
|
*/
|
||||||
|
BUILDIN_FUNC(checkvending) {
|
||||||
TBL_PC *sd = NULL;
|
TBL_PC *sd = NULL;
|
||||||
|
|
||||||
if(script_hasdata(st,2))
|
if (script_hasdata(st,2)) {
|
||||||
sd = map_nick2sd(script_getstr(st,2));
|
if (!(sd = map_nick2sd(script_getstr(st,2)))) {
|
||||||
|
ShowError("buildin_checkvending: Player '%s' is not online!\n", script_getstr(st,2));
|
||||||
|
return SCRIPT_CMD_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
sd = script_rid2sd(st);
|
sd = script_rid2sd(st);
|
||||||
|
|
||||||
if(sd)
|
if (!sd) {
|
||||||
script_pushint(st, sd->state.autotrade ? 2 : sd->state.vending);
|
|
||||||
else
|
|
||||||
script_pushint(st,0);
|
script_pushint(st,0);
|
||||||
return SCRIPT_CMD_SUCCESS;
|
return SCRIPT_CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
int8 ret = 0;
|
||||||
|
if (sd->state.vending)
|
||||||
|
ret |= 1;
|
||||||
|
if (sd->state.autotrade)
|
||||||
|
ret |= 2;
|
||||||
|
if (sd->state.buyingstore)
|
||||||
|
ret |= 4;
|
||||||
|
script_pushint(st, ret);
|
||||||
|
}
|
||||||
|
return SCRIPT_CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BUILDIN_FUNC(checkchatting) // check chatting [Marka]
|
BUILDIN_FUNC(checkchatting) // check chatting [Marka]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user