11.08.2012, 15:20
I created a class selection dialog and made everything and compiled it it got compiled successfully when i added to server it didn't work and i added sscanf and everything
Код:
//====================================Made By Sayko===============================================// #include < a_samp > #include < zcmd > #include <sscanf2> #include <Dini> #define SNIPER_CLASS 1 #define AIRMAN_CLASS 2 #define FLAMETHROWER_CLASS 3 #define ASSAULT_CLASS 4 #define ENGINEER_CLASS 5 #define MEDIC_CLASS 6 #define COLOR_WHITE 0xFFFFFFFF #define COL_GREEN "{6EF83C}" #define COL_WHITE "{FFFFFF}" #define COLOR_RED 0xAA3333AA #define COLOR_GREEN 0x33AA33AA //======================CLASSES FUNCTIONS=====================// new gPlayerClass[MAX_PLAYERS]; public OnPlayerRequestClass(playerid, classid) { ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Classes", "Assault\nSniper\nPilot\nEngineer\nFlameThrower\nMedic", "Select", "Cancel"); return 1; } new PickedClass[MAX_PLAYERS] = 0; //=========================Commands===========================// CMD:switchclass(playerid, params[]) { TogglePlayerControllable(playerid, 0); ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Classes", "Assault\nSniper\nPilot\nEngineer\nPyroman\nMedic", "Select", "Cancel"); SetPlayerVirtualWorld(playerid, 0); return 1; } CMD:classhelp(playerid, params[]) { SendClientMessage(playerid, COLOR_WHITE, ""#COL_GREEN#"Assault: "#COL_WHITE#" Weapon: Desert Eagle , M4 , Shotgun , Tear Gas. "#COL_GREEN#"Score : 0"); SendClientMessage(playerid, COLOR_WHITE, ""#COL_GREEN#"AirMan "#COL_WHITE#"Weapon: 9mm , MP5 , SawnOff , Grenades. [PILOT PLANES], "#COL_GREEN#"Score : 3000"); SendClientMessage(playerid, COLOR_WHITE, ""#COL_GREEN#"FlameThrower "#COL_WHITE#" Weapon: FireThrower, Desert Eagle, Ak_47 "#COL_GREEN#"Score : 300"); SendClientMessage(playerid, COLOR_WHITE, ""#COL_GREEN#"Engineer "#COL_WHITE#"Weapon: 9mm, Tec9, Rocket Launcher "#COL_GREEN#"Score : 700"); SendClientMessage(playerid, COLOR_WHITE, ""#COL_GREEN#"Sniper "#COL_WHITE#"Weapon: Sniper + Silenced 9mm, mp5. "#COL_GREEN#"Score : 0"); SendClientMessage(playerid, COLOR_WHITE, ""#COL_GREEN#"Medic "#COL_WHITE#"Weapon: No Gun[] "#COL_GREEN#"Rank: Private Score: 0"); SendClientMessage(playerid, COLOR_WHITE, ""#COL_GREEN#"Medic "#COL_WHITE#"Medics are in god mode, cause they are in no team :)"); SendClientMessage(playerid, COLOR_WHITE, ""#COL_GREEN#"Medic "#COL_WHITE#"Can use /heal id, to heal someone"); return 1; } CMD:heal(playerid, params[]) { if(gPlayerClass[playerid] == MEDIC_CLASS) { new Float:health, user, Float:x, Float:y, Float:z; if (sscanf(params, "i", user)) return SendClientMessage(playerid, COLOR_WHITE, "[USAGE]: /heal [playerid]"); GetPlayerPos(user, x, y, z); GetPlayerHealth(user, health); if (!IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) return SendClientMessage(playerid, COLOR_WHITE, "You Are Not Close Enough To The Player!"); if (health > 14) return SendClientMessage(playerid, COLOR_WHITE, "Player's Health Is Above 20, And Cannot Be Healed!"); SendClientMessage(playerid, COLOR_WHITE, "You have just been healed!"); SetPlayerHealth(playerid, health + 33); } else return SendClientMessage(playerid,COLOR_WHITE,"You Are Not An Medic!"); return 1; } //============================Dialog System===================================// public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == 1) { if(response) { if(GetPlayerScore(playerid) >= 0)//Private { SetPlayerSkin(playerid, 287); SendClientMessage(playerid, COLOR_WHITE, "You have chosen the assault as your class."); SendClientMessage(playerid, COLOR_WHITE, "You can type /switchclass to change your class again."); gPlayerClass[playerid] = ASSAULT_CLASS; PickedClass[playerid] = 1; SetPlayerVirtualWorld(playerid, 0); TogglePlayerControllable(playerid, 1); GivePlayerWeapon(playerid, 24, 200); GivePlayerWeapon(playerid, 31, 500); GivePlayerWeapon(playerid, 17, 5); } } if(listitem == 1)//sniper DONE { if(GetPlayerScore(playerid) >= 0) { SetPlayerSkin(playerid, 122); SendClientMessage(playerid, COLOR_WHITE, "You have chosen the Sniper as your class."); SendClientMessage(playerid, COLOR_WHITE, "You can type /switchclass to change your class again."); gPlayerClass[playerid] = SNIPER_CLASS; PickedClass[playerid] = 1; SetPlayerVirtualWorld(playerid, 0); TogglePlayerControllable(playerid, 1); GivePlayerWeapon(playerid, 23, 500); GivePlayerWeapon(playerid, 34, 100); GivePlayerWeapon(playerid, 29, 200); } else { SendClientMessage(playerid, COLOR_WHITE, "Use /report if you caught a cheater or Hacker"); TogglePlayerControllable(playerid, 0); } } if(listitem == 2)//pilot DONE { if(GetPlayerScore(playerid) >= 700) { SetPlayerSkin(playerid, 61); SendClientMessage(playerid, COLOR_WHITE, "You chose the Pilot as your class."); SendClientMessage(playerid, COLOR_WHITE, "You can type /switchclass to change your class again."); gPlayerClass[playerid] = AIRMAN_CLASS; PickedClass[playerid] = 1; SetPlayerVirtualWorld(playerid, 0); TogglePlayerControllable(playerid, 1); GivePlayerWeapon(playerid, 22, 50); GivePlayerWeapon(playerid, 29, 500); GivePlayerWeapon(playerid, 16, 5); } else { SendClientMessage(playerid, COLOR_WHITE, "You need to get atleast 700 Score to select this class."); TogglePlayerControllable(playerid, 0); } } if(listitem == 3)//Engineer { if(GetPlayerScore(playerid) >= 700) { SetPlayerSkin(playerid, 285); SendClientMessage(playerid, COLOR_WHITE, "You have chosen the Engineer as your class."); SendClientMessage(playerid, COLOR_WHITE, "You can type /switchclass to change your class again."); gPlayerClass[playerid] = ENGINEER_CLASS; PickedClass[playerid] = 1; SetPlayerVirtualWorld(playerid, 0); TogglePlayerControllable(playerid, 1); GivePlayerWeapon(playerid, 22, 100); GivePlayerWeapon(playerid, 32, 500); GivePlayerWeapon(playerid, 35, 5); } else { SendClientMessage(playerid, COLOR_WHITE, "You need to get 700 Score to select this class."); TogglePlayerControllable(playerid, 0); } } if(listitem == 4)//FlameThrower { if(GetPlayerScore(playerid) >= 300) { SetPlayerSkin(playerid, 144); SendClientMessage(playerid, COLOR_WHITE, "You have chosen the Flamethrower as your class."); SendClientMessage(playerid, COLOR_WHITE, "You can type /switchclass to change your class again."); gPlayerClass[playerid] = FLAMETHROWER_CLASS; PickedClass[playerid] = 1; SetPlayerVirtualWorld(playerid, 0); TogglePlayerControllable(playerid, 1); GivePlayerWeapon(playerid, 24, 200); GivePlayerWeapon(playerid, 30, 200); GivePlayerWeapon(playerid, 37, 200); } else { SendClientMessage(playerid, COLOR_WHITE, "You need to get 300 Score to select this class."); TogglePlayerControllable(playerid, 0); } } if(listitem == 5)//Medic { if(GetPlayerScore(playerid) >= 0) { SetPlayerSkin(playerid, 274);//medic skin SendClientMessage(playerid, COLOR_WHITE, "You chose the Medic Class as your class. [/heal to heal someone]"); SendClientMessage(playerid, COLOR_WHITE, "You can type /switchclass to change your class again."); gPlayerClass[playerid] = MEDIC_CLASS; PickedClass[playerid] = 1; SetPlayerVirtualWorld(playerid, 0); TogglePlayerControllable(playerid, 1); SetPlayerHealth(playerid, 999999); } } return 1; } return 1; } //==================== public OnPlayerConnect(playerid) { LoadStats(playerid); return 1; } public OnPlayerDisconnect(playerid) { SaveStats(playerid); return 1; } public OnPlayerDeath(playerid, killerid, reason) { SendClientMessage(playerid, COLOR_WHITE, "Stats Saved."); SaveStats(playerid); return 1; } forward SaveStats(playerid); public SaveStats(playerid){ new string[MAX_PLAYER_NAME + 12]; if(GetPlayerName(playerid,string,sizeof(string))){ format(string,sizeof(string),"scores/%s.ini",string); if(!dini_Exists(string)) dini_Create(string); dini_IntSet(string,"Score",GetPlayerScore(playerid)); } return true; } forward LoadStats(playerid); public LoadStats(playerid){ new string[MAX_PLAYER_NAME + 12]; if(GetPlayerName(playerid,string,sizeof(string))){ format(string,sizeof(string),"scores/%s.ini",string); if(dini_Exists(string)){ SetPlayerScore(playerid,dini_Int(string,"Score")); } } return true; } //====================================Made By Sayko===============================================/