31.03.2015, 18:38
(
Последний раз редактировалось Just1c3; 31.03.2015 в 20:25.
Причина: better to understand
)
Hey!
I'm trying to spawn a player at a specific location after logging-in on a dialog.
Altho the player gets spawned at random locations..
This is my (full)code:
What is wrong with this code??
I'm trying to spawn a player at a specific location after logging-in on a dialog.
Altho the player gets spawned at random locations..
This is my (full)code:
Код:
#include <a_samp> #include <strlib> #include <zcmd> #include <a_mysql> #define FILTERSCRIPT #if defined FILTERSCRIPT new mysql; public OnFilterScriptInit() { print("\n--------------------------------------"); print("SERVER JUSTUS LOL11"); print("--------------------------------------\n"); return 1; } public OnFilterScriptExit() { return 1; } public OnGameModeInit() { mysql_debug(1); if(mysql = mysql_connect("","","","")) { print("connected mysql! :D"); } CreateObject(18769, 3063.20068, 2099.88599, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3005.37500, 2099.47681, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3022.95557, 2099.57886, -0.05917, 0.00000, 0.00000, 0.06000); CreateObject(18769, 3005.00854, 2119.26172, -0.05917, 0.00000, 0.00000, 0.30000); CreateObject(18769, 3043.14429, 2099.48706, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3022.95557, 2099.57886, -0.05917, 0.00000, 0.00000, 0.06000); CreateObject(18769, 3005.37500, 2099.47681, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3043.14429, 2099.48706, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3022.95557, 2099.57886, -0.05917, 0.00000, 0.00000, 0.06000); CreateObject(18769, 3005.37500, 2099.47681, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3043.14429, 2099.48706, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3022.95557, 2099.57886, -0.05917, 0.00000, 0.00000, 0.06000); CreateObject(18769, 3005.37500, 2099.47681, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3043.14429, 2099.48706, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3022.95557, 2099.57886, -0.05917, 0.00000, 0.00000, 0.06000); CreateObject(18769, 3005.37500, 2099.47681, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3043.14429, 2099.48706, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3022.95557, 2099.57886, -0.05917, 0.00000, 0.00000, 0.06000); CreateObject(18769, 3005.37500, 2099.47681, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3043.14429, 2099.48706, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3022.95557, 2099.57886, -0.05917, 0.00000, 0.00000, 0.06000); CreateObject(18769, 3005.37500, 2099.47681, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3043.14429, 2099.48706, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3022.95557, 2099.57886, -0.05917, 0.00000, 0.00000, 0.06000); CreateObject(18769, 3005.37500, 2099.47681, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3043.14429, 2099.48706, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3022.95557, 2099.57886, -0.05917, 0.00000, 0.00000, 0.06000); CreateObject(18769, 3005.37500, 2099.47681, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3043.14429, 2099.48706, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3022.95557, 2099.57886, -0.05917, 0.00000, 0.00000, 0.06000); CreateObject(18769, 3005.37500, 2099.47681, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3043.14429, 2099.48706, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3022.95557, 2099.57886, -0.05917, 0.00000, 0.00000, 0.06000); CreateObject(18769, 3044.31812, 2139.56323, -0.05917, 0.00000, 0.00000, 0.30000); CreateObject(18769, 3043.14429, 2099.48706, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3022.95557, 2099.57886, -0.05917, 0.00000, 0.00000, 0.06000); CreateObject(18769, 3024.49072, 2139.72632, -0.05917, 0.00000, 0.00000, 0.30000); CreateObject(18769, 3043.14429, 2099.48706, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3022.95557, 2099.57886, -0.05917, 0.00000, 0.00000, 0.06000); CreateObject(18769, 3004.51807, 2139.35889, -0.05917, 0.00000, 0.00000, 0.30000); CreateObject(18769, 3043.14429, 2099.48706, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3022.95557, 2099.57886, -0.05917, 0.00000, 0.00000, 0.06000); CreateObject(18769, 3063.82056, 2119.64282, -0.05917, 0.00000, 0.00000, 0.30000); CreateObject(18769, 3043.14429, 2099.48706, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3022.95557, 2099.57886, -0.05917, 0.00000, 0.00000, 0.06000); CreateObject(18769, 3046.18384, 2119.43433, -0.05917, 0.00000, 0.00000, 0.30000); CreateObject(18769, 3043.14429, 2099.48706, -0.05917, 0.00000, 0.00000, 0.00000); CreateObject(18769, 3022.95557, 2099.57886, -0.05917, 0.00000, 0.00000, 0.06000); CreateObject(18769, 3084.04150, 2139.74731, -0.05917, 0.00000, 0.00000, 0.30000); CreateObject(18769, 3064.06006, 2139.75171, -0.05917, 0.00000, 0.00000, 0.30000); CreateObject(18769, 3083.13184, 2099.67871, -0.05917, 0.00000, 0.00000, 0.30000); CreateObject(18769, 3084.11621, 2119.80078, -0.05917, 0.00000, 0.00000, 0.30000); CreateObject(18769, 3026.08862, 2119.53833, -0.05917, 0.00000, 0.00000, 0.30000); CreateObject(18769, 3024.53491, 2119.30200, -0.05917, 0.00000, 0.00000, 0.30000); return 1; } new VehicleNames[212][] = { "Landstalker","Bravura","Buffalo","Linerunner","Pereniel","Sentinel","Dumper","Firetruck","Trashmaster","Stretch","Manana","Infernus", "Voodoo","Pony","Mule","Cheetah","Ambulance","Leviathan","Moonbeam","Esperanto","Taxi","Washington","Bobcat","Mr Whoopee","BF Injection", "Hunter","Premier","Enforcer","Securicar","Banshee","Predator","Bus","Rhino","Barracks","Hotknife","Trailer","Previon","Coach","Cabbie", "Stallion","Rumpo","RC Bandit","Romero","Packer","Monster","Admiral","Squalo","Seasparrow","Pizzaboy","Tram","Trailer","Turismo","Speeder", "Reefer","Tropic","Flatbed","Yankee","Caddy","Solair","Berkley's RC Van","Skimmer","PCJ-600","Faggio","Freeway","RC Baron","RC Raider", "Glendale","Oceanic","Sanchez","Sparrow","Patriot","Quad","Coastguard","Dinghy","Hermes","Sabre","Rustler","ZR3 50","Walton","Regina", "Comet","BMX","Burrito","Camper","Marquis","Baggage","Dozer","Maverick","News Chopper","Rancher","FBI Rancher","Virgo","Greenwood", "Jetmax","Hotring","Sandking","Blista Compact","Police Maverick","Boxville","Benson","Mesa","RC Goblin","Hotring Racer A","Hotring Racer B", "Bloodring Banger","Rancher","Super GT","Elegant","Journey","Bike","Mountain Bike","Beagle","Cropdust","Stunt","Tanker","RoadTrain", "Nebula","Majestic","Buccaneer","Shamal","Hydra","FCR-900","NRG-500","HPV1000","Cement Truck","Tow Truck","Fortune","Cadrona","FBI Truck", "Willard","Forklift","Tractor","Combine","Feltzer","Remington","Slamvan","Blade","Freight","Streak","Vortex","Vincent","Bullet","Clover", "Sadler","Firetruck","Hustler","Intruder","Primo","Cargobob","Tampa","Sunrise","Merit","Utility","Nevada","Yosemite","Windsor","Monster A", "Monster B","Uranus","Jester","Sultan","Stratum","Elegy","Raindance","RC Tiger","Flash","Tahoma","Savanna","Bandito","Freight","Trailer", "Kart","Mower","Duneride","Sweeper","Broadway","Tornado","AT-400","DFT-30","Huntley","Stafford","BF-400","Newsvan","Tug","Trailer A","Emperor", "Wayfarer","Euros","Hotdog","Club","Trailer B","Trailer C","Andromada","Dodo","RC Cam","Launch","Police Car (LSPD)","Police Car (SFPD)", "Police Car (LVPD)","Police Ranger","Picador","S.W.A.T. Van","Alpha","Phoenix","Glendale","Sadler","Luggage Trailer A","Luggage Trailer B", "Stair Trailer","Boxville","Farm Plow","Utility Trailer" }; new WeaponNames[47][]={//weapons "Fist", "Brass Knuckles", "Golf Club", "Nightstick", "Knife", "Baseball Bat", "Shovel", "Pool Cue", "Katana", "Chainsaw", "Double Dildo", "Dildo", "Vibrator", "Silver Vibrator", "Flowers", "Cane", "Grenade", "Tear Gas", "Molotov Cocktail", "", "", "", "9mm", "Silences 9mm", "Desert Eagle", "Shotgun", "Sawnoff Shotgun", "Combat Shotgun", "Micro SMG", "MP5", "AK47", "M4", "Tec9", "Country Rifle", "Sniper Rifle", "Rocket Launcher", "HeatSeek Rocket Launcher", "Flamethrower", "Minigun", "Satchel Charge", "Detonator", "Spraycan", "Fire Extinguisher", "Camera", "Night Vision Goggles", "Thermal Goggles", "Parachute" }; /*COMMAND:givevehicle(playerid, params[]) { if (!isnull(params)) { for(new i = 0; i < sizeof(VehicleNames); i++) { if(strfind(VehicleNames[i], params, true) != -1) { new Float:x, Float:y, Float:z, Float:az; GetPlayerPos(playerid, x, y, z); GetPlayerFacingAngle(playerid, az); CreateVehicle(i + 400, x+5, y+5, z, az, -1, -1, 180); new result[128]; format(result, sizeof(result), "%s has been spawned.", VehicleNames[i]); SendClientMessage(playerid, -1, result); break; } } } return 1; } COMMAND:giveweapon(playerid, params[]) { if (!isnull(params)) { for(new i = 0; i < sizeof(WeaponNames); i++) { if(strfind(WeaponNames[i], params, true) != -1) { GivePlayerWeapon(playerid, i, 25); new result[128]; format(result, sizeof(result), "%s has been given.", WeaponNames[i]); SendClientMessage(playerid, -1, result); break; } } } return 1; }*/ forward DestroyTextTimer(Text:text); TimeTextForPlayer(playerid, Text:text, time) { TextDrawShowForPlayer(playerid,text); SetTimerEx("DestroyTextTimer",time,0,"i",_:text); // _: from Simon } public DestroyTextTimer(Text:text) { TextDrawDestroy(text); } public OnPlayerConnect(playerid) { new Text:welcomeText; new name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); format(string, sizeof(string), "%s Welcome to Justus Server", name); welcomeText = TextDrawCreate(320.0, 150.0,string); TextDrawAlignment(welcomeText, 2); // Align the textdraw in the center TextDrawColor(welcomeText, 0xFF0000FF); TimeTextForPlayer(playerid,welcomeText,6000); ShowAuth(playerid); return 1; } enum { DIALOG_AUTH, DIALOG_REGISTER, DIALOG_LOGIN } enum { PLAYER_TYPE_NORMAL, PLAYER_TYPE_ADMIN } PlayerSpawn(playerid, PLAYER_TYPE, xpos, ypos, zpos) { if(PLAYER_TYPE == PLAYER_TYPE_NORMAL) { SetSpawnInfo(playerid, 2, 0,2488.6750,-1667.1787,13.3438,200.0000,0,0); SpawnPlayer(playerid); } /*if(PLAYER_TYPE == PLAYER_TYPE_NORMAL) { SetSpawnInfo(playerid, 1, 3, 1958.33, 1343.12, 15.36, 269.15, 26, 36, 28, 150, 0, 0 ); SpawnPlayer(playerid); }*/ } ShowAuth(playerid) { ShowPlayerDialog(playerid,DIALOG_AUTH, DIALOG_STYLE_MSGBOX, "Authentication", "Register or Login", "Login", "Register"); } ShowRegister(playerid) { ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT, "Login", "Enter a strong password", "Register", "Cancel"); } ShowLogin(playerid) { ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT, "Login", "Enter your password", "Login", "Cancel"); } PlayerLogin(playerid, password[]) { new name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); new result[128]; format(result, sizeof(result), "SELECT `name`,`password` FROM `players` WHERE name = '%s' AND password = MD5('%s')", name,password); mysql_query(mysql, result, true); new rows = cache_num_rows(); new result2[128]; format(result2, sizeof(result2), "rows: %i", rows); SendClientMessage(playerid, -1, result2); if(rows > 0) { return true; } return false; } public OnPlayerRequestClass(playerid, classid) { return 1; } PlayerRegister(playerid, password[]) { new name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); new result[128]; format(result, sizeof(result), "INSERT INTO `players` (`name`,`password`) VALUES('%s',MD5('%s'))", name,password); if(mysql_query(mysql,result)) { return true; } return false; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == DIALOG_AUTH) { if(response) { ShowLogin(playerid); } else { ShowRegister(playerid); } return 1; } if(dialogid == DIALOG_LOGIN) { if(response) { if(PlayerLogin(playerid,inputtext)) { TogglePlayerSpectating(playerid, 0); SendClientMessage(playerid, -1, "You've been logged-in!!"); SetSpawnInfo( playerid, 0,1, 3028.1204,2128.2229,1.6049,76.2389, 26, 36, 28, 150, 0, 0 ); SpawnPlayer(playerid); //PlayerSpawn(playerid,PLAYER_TYPE_NORMAL,2488.6750,-1667.1787,13.3438,200.0000); } } else { ShowAuth(playerid); } return 1; } if(dialogid == DIALOG_REGISTER) { if(response) { if(PlayerRegister(playerid,inputtext)) { SendClientMessage(playerid, -1, "Your account has been created! You may now login."); ShowLogin(); } } else { ShowAuth(playerid); } return 1; } return 0; // You MUST return 0 here! Just like OnPlayerCommandText. } #else main() { print("\n----------------------------------"); print(" Blank Gamemode by your name here"); print("----------------------------------\n"); } #endif