11.12.2014, 13:38
Hello i making sql registration on my server but i but sql give my error i think is about npc cuz i have 3 npc on my server and they register like a users or simething like that the error i get is :
can some1 help my to fix it
This is mane game mode file
Код:
[14:13:50] [ERROR] CMySQLQuery::Execute[OnUserCheck] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'name='LSTrain2'' at line 1 [14:13:50] [ERROR] CMySQLQuery::Execute[OnUserCheck] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'name='SFTrain1'' at line 1 [14:13:50] [ERROR] CMySQLQuery::Execute[OnUserCheck] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'name='LVTrain3'' at line 1
This is mane game mode file
Код:
#include <a_samp> #include <core> #include <a_mysql> #include <sscanf2> #include <float> #include "../include/gl_common.inc" #include "../include/gl_spawns.inc" #pragma tabsize 0 //---------------------------------------------------------- #define COLOR_WHITE 0xFFFFFFFF #define COLOR_NORMAL_PLAYER 0xFFBB7777 //dialogs--- #define DIALOG_REGISTER 2 new total_vehicles_from_files=0; //forwards forward OnUserCheck(playerid); //---------------------------------------------------------- main() { print("\n---------------------------------------"); print("Running Grand Larceny - by the SA-MP team\n"); print("---------------------------------------\n"); } //---------------------------------------------------------- //--------------------SQL Connect-------------------------------------- #define mysql_host "127.0.0.1" #define mysql_user "cyberlord" #define mysql_password "a8021c" #define mysql_database "samp" new sqlconnect; //-------------NPC trains ------------- new Text3D:NPCTextTrain1; new Text3D:NPCTextTrain2; new Text3D:NPCTextTrain3; new SFTrain1NPCVehicle; new LSTrain2NPCVehicle; new LVTrain3NPCVehicle; //---------------- public OnGameModeInit() { SetGameModeText("Grand Larceny"); ShowPlayerMarkers(PLAYER_MARKERS_MODE_GLOBAL); ShowNameTags(1); SetNameTagDrawDistance(40.0); EnableStuntBonusForAll(0); DisableInteriorEnterExits(); SetWeather(2); SetWorldTime(11); UsePlayerPedAnims(); //ManualVehicleEngineAndLights(); //LimitGlobalChatRadius(300.0); // Player Class AddPlayerClass(281,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(282,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(283,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(284,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(285,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(286,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(287,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(288,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(289,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(265,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(266,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(267,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(268,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(269,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(270,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(1,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(2,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(3,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(4,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(5,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(6,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(8,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(42,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(65,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); //AddPlayerClass(74,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(86,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(119,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(149,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(208,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(273,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(289,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(47,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(48,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(49,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(50,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(51,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(52,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(53,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(54,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(55,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(56,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(57,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(58,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(68,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(69,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(70,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(71,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(72,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(73,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(75,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(76,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(78,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(79,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(80,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(81,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(82,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(83,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(84,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(85,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(87,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(88,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(89,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(91,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(92,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(93,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(95,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(96,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(97,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(98,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); AddPlayerClass(99,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); // SPECIAL total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/pilots.txt"); // LAS VENTURAS total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_law.txt"); total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_airport.txt"); total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_gen.txt"); // SAN FIERRO total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_law.txt"); total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_airport.txt"); total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_gen.txt"); // LOS SANTOS total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_law.txt"); total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_airport.txt"); total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_gen_inner.txt"); total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_gen_outer.txt"); // OTHER AREAS total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/whetstone.txt"); total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/bone.txt"); total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/flint.txt"); total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/tierra.txt"); total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/red_county.txt"); printf("Total vehicles from files: %d",total_vehicles_from_files); //------------- train ----------------- NPCTextTrain1 = Create3DTextLabel("San Feriero Transport Company Train", 0x6495EDFF, 0.0, 0.0, 0.0, 30.0,0, 0); NPCTextTrain2 = Create3DTextLabel("Los Santos Transport Company Train ", 0x6495EDFF, 0.0, 0.0, 0.0, 30.0,0, 0); NPCTextTrain3 = Create3DTextLabel("Los Venturas Transport Company Train ", 0x6495EDFF, 0.0, 0.0, 0.0, 30.0,0, 0); ConnectNPC("SFTrain1","train1"); ConnectNPC("LSTrain2","train2"); ConnectNPC("LVTrain3","train3"); SFTrain1NPCVehicle = CreateVehicle(400,-1942.7950,168.4164,27.0006,200.0,-1,-1, 500); LSTrain2NPCVehicle = CreateVehicle(400,1700.7551,-1953.6531,14.8756,200.0,-1,-1, 500); LVTrain3NPCVehicle = CreateVehicle(400,1462.0745,2630.8787,10.8203,200.0,-1,-1, 500); //sql connect sqlconnect = mysql_connect(mysql_host,mysql_user,mysql_database ,mysql_password); return 1; } //-------------------------------------------------- public OnGameModeExit() { mysql_close(sqlconnect); return 1; } //--------------------- public OnPlayerRequestClass(playerid, classid) { if(IsPlayerNPC(playerid)) return 1; SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746); SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746); SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746); return 1; } //------------------------ public OnUserCheck(playerid) { new num_rows,num_fields; cache_get_data(num_rows,num_fields,sqlconnect);// get data from db if(num_rows == 0){ //checks db if is empty gives u register else login //register ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Tu dar nesi uzsiregistraves","Iveskite slaptazody:","Registruotis","Iseiti"); }else { //login } return 1; } //------------- public OnPlayerConnect(playerid) { //---------------------Massage on connect screen---------------------------------- GameTextForPlayer(playerid,"~w~Grand Larceny",3000,4); SendClientMessage(playerid,COLOR_WHITE,"Welcome to {88AA88}G{FFFFFF}rand {88AA88}L{FFFFFF}arceny"); //Login / register------------ new name[MAX_PLAYER_NAME],query[128]; GetPlayerName(playerid,name,sizeof(name)); format(query,sizeof(query),"SELECT id FROM accounts WHARE name='%s'",name); mysql_function_query(sqlconnect,query,true,"OnUserCheck","i",playerid); return 1; } public OnPlayerSpawn(playerid) { //-------------------------Train NPC----------------------------- if(IsPlayerNPC(playerid)) //Checks if the player that just spawned is an NPC. { new npcname[MAX_PLAYER_NAME]; GetPlayerName(playerid, npcname, sizeof(npcname)); //Getting the NPC's name. if(!strcmp(npcname, "SFTrain1", true)) //Checking if the NPC's name is MyFirstNPC { PutPlayerInVehicle(playerid, SFTrain1NPCVehicle, 0); Attach3DTextLabelToVehicle(NPCTextTrain1, SFTrain1NPCVehicle, 0.0, 0.0, 0.0); return 1; } if(!strcmp(npcname, "LSTrain2", true)) { PutPlayerInVehicle(playerid, LSTrain2NPCVehicle, 0); Attach3DTextLabelToVehicle(NPCTextTrain2, LSTrain2NPCVehicle, 0.0, 0.0, 0.0); return 1; } if(!strcmp(npcname, "LVTrain3", true)) { PutPlayerInVehicle(playerid, LVTrain3NPCVehicle, 0); Attach3DTextLabelToVehicle(NPCTextTrain3, LVTrain3NPCVehicle, 0.0, 0.0, 0.0); return 1; } return 1; } //---------------------------------------------- if(IsPlayerNPC(playerid))return 1; SetPlayerInterior(playerid,0); TogglePlayerClock(playerid,0); ResetPlayerMoney(playerid); GivePlayerMoney(playerid, 30000); //SetPlayerColor(playerid,COLOR_NORMAL_PLAYER); SetPlayerSkillLevel(playerid,WEAPONSKILL_PISTOL,200); SetPlayerSkillLevel(playerid,WEAPONSKILL_PISTOL_SILENCED,200); SetPlayerSkillLevel(playerid,WEAPONSKILL_DESERT_EAGLE,200); SetPlayerSkillLevel(playerid,WEAPONSKILL_SHOTGUN,200); SetPlayerSkillLevel(playerid,WEAPONSKILL_SAWNOFF_SHOTGUN,200); SetPlayerSkillLevel(playerid,WEAPONSKILL_SPAS12_SHOTGUN,200); SetPlayerSkillLevel(playerid,WEAPONSKILL_MICRO_UZI,200); SetPlayerSkillLevel(playerid,WEAPONSKILL_MP5,200); SetPlayerSkillLevel(playerid,WEAPONSKILL_AK47,200); SetPlayerSkillLevel(playerid,WEAPONSKILL_M4,200); SetPlayerSkillLevel(playerid,WEAPONSKILL_SNIPERRIFLE,200); GivePlayerWeapon(playerid,WEAPON_COLT45,100); //GivePlayerWeapon(playerid,WEAPON_MP5,100); TogglePlayerClock(playerid, 0); return 1; } //---------------------------------------------------------- public OnPlayerDeath(playerid, killerid, reason) { new playercash; // if they ever return to class selection make them city // select again first if(killerid == INVALID_PLAYER_ID) { ResetPlayerMoney(playerid); } else { playercash = GetPlayerMoney(playerid); if(playercash > 0) { GivePlayerMoney(killerid, playercash); ResetPlayerMoney(playerid); } } return 1; } //---------------------------------------------------------- //---------------------------------------------------------- // Used to init textdraws of city names ClassSel_InitCityNameText(Text:txtInit) { TextDrawUseBox(txtInit, 0); TextDrawLetterSize(txtInit,1.25,3.0); TextDrawFont(txtInit, 0); TextDrawSetShadow(txtInit,0); TextDrawSetOutline(txtInit,1); TextDrawColor(txtInit,0xEEEEEEFF); TextDrawBackgroundColor(txtClassSelHelper,0x000000FF); } //---------------------------------------------------------- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { return 1; } //--------------------------- public OnPlayerUpdate(playerid) { if(!IsPlayerConnected(playerid)) return 0; if(IsPlayerNPC(playerid)) return 1; // No weapons in interiors if(GetPlayerInterior(playerid) != 0 && GetPlayerWeapon(playerid) != 0) { SetPlayerArmedWeapon(playerid,0); // fists return 0; // no syncing until they change their weapon } // Don't allow minigun if(GetPlayerWeapon(playerid) == WEAPON_MINIGUN) { Kick(playerid); return 0; } /* No jetpacks allowed if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USEJETPACK) { Kick(playerid); return 0; }*/ /* For testing animations new msg[128+1]; new animlib[32+1]; new animname[32+1]; thisanimid = GetPlayerAnimationIndex(playerid); if(lastanimid != thisanimid) { GetAnimationName(thisanimid,animlib,32,animname,32); format(msg, 128, "anim(%d,%d): %s %s", lastanimid, thisanimid, animlib, animname); lastanimid = thisanimid; SendClientMessage(playerid, 0xFFFFFFFF, msg); }*/ return 1; } //----------------------------------------------------------