Question regarding two different commands, not showing properly
#1

So I have two questions regarding two different commands, pretty much. I'm currently working on an All Points Bulletin command. So there's a /newapb command, where you will have to write /newapb create in order to create. It's the create code I need help with, because it apparently does not want to work with me. I'm new to this and don't see the logic in it right now, like how to bring some info of the code to the next part (dialog wise).

The "create" of /makeapb (yes, there's multiple different strings, here's the create one):
Code:
else if(CompareStrings(action, "create")) // HAS TO BE FIXED
	{

		if(sscanf(params,"{s[64]}d",number)) return SyntaxMSG(playerid, "/apb create [number]");
		if(ApbInfo[number][apbOn]) return SCM(playerid, COLOR_GREY, "This APB already exists.");
		Dialog_Show(playerid, APBCreate, DIALOG_STYLE_INPUT, "APB Creation", "", "Submit", "Cancel");
	}
So I made that dialog (using easyDialogs by the way). The dialog looks like this:
So that "number" is supposed to be the one you write when you do /makeapb create NUMBERHERE
.. and should be brought to this dialog eh?
Code:
Dialog:APBCreate(playerid, response, listitem, inputtext[])
{
	if(response)
	{
		new number, charge[256];
		if(strlen(inputtext) < 7 || strlen(inputtext) > 100) return Dialog_Show(playerid, APBCreate, DIALOG_STYLE_INPUT, "APB Creation", "The APB must contain between 3-100 characters", "Submit", "Cancel");
		SCMEx(playerid, COLOR_LIGHTRED, "You have created APB number: %d.", number);
		format(ApbInfo[number][apbCharge], 256, "%s", inputtext);
		ApbInfo[number][apbOfficer] = GetNameEx(playerid);
		ApbInfo[number][apbPage] = number;
		ApbInfo[number][apbID] = number;
		ApbInfo[number][apbOn] = 1;
		OnApbCreate(number, ApbInfo[number][apbCharge], GetNameEx(playerid));
	}
	return 1;
}
Right now, nothiing happens when I write it. If I follow the syntax of course, otherwise it's an "unknown command".


My other question is regarding my /namechange command. So in the script that I am using you can have multiple vehicles, but only one spawned at a time. So when I do namechange I'd like it to update the owner of the vehicles that is in his name. E.g a player's named John Doe. He wants namechange to Doe John, and I want to update his vehicles so it is in his new name - that way he'll keep the vehicle.

Right now this is the part of namechange that should change the owner of the vehicle, but doesn't:
Code:
for(new i = 0; i < MAX_VEHICLES; i++)
	{
		if(CompareStrings(VehicleInfo[i][carOwner], GetName(id)))
		{
			format(VehicleInfo[i][carOwner], MAX_PLAYER_NAME, "%s", name);
		}
	}
Ontop of the namechange command:
Code:
new id,name[MAX_PLAYER_NAME];
Error I get when using namechange command:
Code:
[DEBUG] mysql_tquery - connection: 1, query: "UPDATE `ownedvehicles` SET `plate` = 'DM' WHERE `owner` = 'John", callback: "(null)", format: "(null)"
[ERROR] CMySQLQuery::Execute[] - (error #1054) Unknown column 'Doe_John' in 'field list'
Reply
#2

Firstly, you'll have to create an extra variable to store the number parameter in and then use it in the dialog.
Secondly, you shouldn't link tables through the name, but rather through their ID - It's the primary key of the user's table. The reason for that is because the ID is not likely to change after creating it and also because it is more efficient scanning through integers than it is through strings. I advise you to make it AUTO_INCREMENT too, if it wasn't already.
Reply
#3

Quote:
Originally Posted by AndySedeyn
View Post
Firstly, you'll have to create an extra variable to store the number parameter in and then use it in the dialog.
Secondly, you shouldn't link tables through the name, but rather through their ID - It's the primary key of the user's table. The reason for that is because the ID is not likely to change after creating it and also because it is more efficient scanning through integers than it is through strings. I advise you to make it AUTO_INCREMENT too, if it wasn't already.
It is A_I, and yes I know. Problem is that the whole gamemode is pretty much based on playernames now. Will try to change that eventually. Testing with variables now.

Update: The dialog still doesn't show up. This is what I did:
At the "create" string:
Code:
SetIntVar(playerid, "APBNumber", number);
		if(sscanf(params,"{s[64]}d",number)) return SyntaxMSG(playerid, "/apb create [number]");
		if(ApbInfo[number][apbOn]) return SCM(playerid, COLOR_GREY, "This APB already exists.");
		Dialog_Show(playerid, APBCreate, DIALOG_STYLE_INPUT, "APB Creation", "", "Submit", "Cancel");
The actual dialog:
Code:
Dialog:APBCreate(playerid, response, listitem, inputtext[])
if(response)
	{
		new number, charge[256];
		if(strlen(inputtext) < 7 || strlen(inputtext) > 100) return Dialog_Show(playerid, APBCreate, DIALOG_STYLE_INPUT, "APB Creation", "The APB must contain between 3-100 characters", "Submit", "Cancel");
		number = GetIntVar(playerid, "APBNumber");
		SCMEx(playerid, COLOR_LIGHTRED, "You have created APB number: %d.", number);
		ApbInfo[number][apbCharge], 256, "%s", inputtext);
		ApbInfo[number][apbOfficer] = GetNameEx(playerid);
		ApbInfo[number][apbPage] = number;
		ApbInfo[number][apbID] = number;
		ApbInfo[number][apbOn] = 1;
		OnApbCreate(number, ApbInfo[number][apbCharge], GetNameEx(playerid));
		RemoveVar(playerid, "APBNumber");
	}
.. and after compiling it seems like that is not how you use a variable.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)