Page 2 of 2
Re: /modify command
Posted: Thu Jun 15, 2017 4:59 pm
by Cynnar
I just hope I get an A for effort.

Re: /modify command
Posted: Thu Jun 15, 2017 6:01 pm
by Jabantiz
I assume this is in "/modify spawn" so the actual command in game would be "/modify spawn door"
If that is the case then you want to check against the 0 index for door
Code: Select all
if (strcmp(sep->arg[0], "door") == 0) {
Also this line can cause a lot of problems
Code: Select all
Widget* target = (Widget*)client->GetPlayer()->GetTarget();
GetTarget() will only return a Spawn* and then you forcing it to a widget, the problems comes when some on uses this command on a spawn that is not actually a widget so you don't want to do it like this, you first want to get a Spawn* check to see if it is valid and check to see if it is a widget, something like this
Code: Select all
Spawn* target = client->GetPlayer()->GetTarget();
if (target && target->IsWidget()) {
Widget* widget = (Widget*)target;
// now you can use the widget pointer without casting it to anything like so
widget->GetIncludeHeading();
}
Re: /modify command
Posted: Thu Jun 15, 2017 8:59 pm
by Cynnar
As always Jab you are the man. Yes this is in the /modify spawn command
I dunno how, or why, I got arg[1] instead of arg[0], but I did.
John Adams wrote: Tue Jan 21, 2014 7:31 pm
/modify was supposed to replace many of the old commands
I guess it would be better to have
Code: Select all
if (strcmp(sep->arg[0], "door") == 0)
{
if (strcmp(sep->arg[1], "details") == 0)
Since modify is to replace the old commands to make /modify spawn door details to replace the spawn details command?
Re: /modify command
Posted: Thu Jun 15, 2017 9:06 pm
by Jabantiz
I think "/modify spawn details" would be the best bet to replace /spawn details, that way you don't need to make a details command for each type (widget, npc, sign, etc...)
Re: /modify command
Posted: Fri Jun 16, 2017 2:06 am
by Cynnar
Ok so I have copied over the spawn details code to modify spawn details. Tested and it works.
I have noticed when you get the details (in both commands) it will print the type for the spawn id.
Code: Select all
client->Message(CHANNEL_COLOR_YELLOW, "Name: %s, %s ID: %u", spawn->GetName(), type, spawn->GetDatabaseID());
Which is ok if it is the only id. If I add in the information from the spawn_widget table then we have spawn_id, and widget id and it might become confusing since the message shows Widget ID: 1841456 when the actual widget id is 473155622 in the spawn_widget table. Would it be better to have it display Widget Spawn ID instead of the Widget ID? I also assume that the id, not spawn_id or widget_id, in the spawn_widgets table would be ok to leave out of the details command, but if it needs to be there as well it is something else to make clear also.
What about displaying include_heading with a Yes or No instead of 0 or 1? It makes it easier to read with the Yes and No.
Edit: When I add in this code
Code: Select all
((Widget*)spawn)->GetIncludeHeading() > 0 ? "Yes" : "No"
I get a warning C4804: '>' : unsafe use of type 'bool' in operation. Should I do this a different way?
Re: /modify command
Posted: Fri Jun 16, 2017 3:30 am
by Jabantiz
Really it would be fine to have it as ID: for the spawn id and no need to include widget at all at this point. The ID in the widgets table doesn't need to be included, it can be looked up with the spawn id.
GetIncludeHeading() returns a bool it look like from that warning and you compare it to an int, visual studio tends to not like that so you could just change the " > 0" to "== true"
Re: /modify command
Posted: Fri Jun 23, 2017 3:18 pm
by Cynnar
I'm going to replace the door with widget so the command will be /modify spawn widget. This way the command can be entered as /modify spawn widget heading, or /modify spawn widget type. I think that would make more sense in the end.
Thoughts on this anyone?
Edit:
I was wondering if I should spend more time on moving each of the spawn details items to its own line? Here is a screenshot of the first few in the list.
spawndetails.png
Re: /modify command
Posted: Fri Jun 23, 2017 5:05 pm
by Cynnar
Here is what I am going for with the spawn details command.
spawndetails2.png