SHOW:
|
|
- or go back to the newest paste.
| 1 | ||
| 2 | //------------------------------------------------------------------[ Includes ] | |
| 3 | #include <a_samp> | |
| 4 | #include <a_mysql> | |
| 5 | #include <time> | |
| 6 | #include <file> // système de log par exemple | |
| 7 | #include <sscanf2> | |
| 8 | //-------------------------------------------------------------[Connexion ] | |
| 9 | #define mysql_host "127.0.0.1" //Has to be a string | |
| 10 | #define mysql_user "root" //Has to be a string | |
| 11 | #define mysql_password "" //There is none for wamp unless you set one. | |
| 12 | - | #define mysql_password "an1106" //There is none for wamp unless you set one. |
| 12 | + | #define mysql_database "" //Has to be a string |
| 13 | - | #define mysql_database "LSI-RP" //Has to be a string |
| 13 | + | |
| 14 | #define JoueursMax GetMaxPlayers() | |
| 15 | #define MaxVoiture MAX_VEHICLES | |
| 16 | #define MaxObjets MAX_OBJECTS | |
| 17 | //--------------------------------------------------------------------[ Colors ] | |
| 18 | #define Noir "{000000}"
| |
| 19 | #define Blanc "{FFFFFF}"
| |
| 20 | #define Gris "{BFBFBF}"
| |
| 21 | #define Rouge "{FF0000}"
| |
| 22 | #define Orange "{FFA500}"
| |
| 23 | #define Jaune "{FFFF00}"
| |
| 24 | #define Vert "{008000}"
| |
| 25 | #define Bleu "{0000FF}"
| |
| 26 | #define Violet "{800080}"
| |
| 27 | #define Teal "{008080}"
| |
| 28 | //--------------------------------------------------------------[ Milliseconds ] | |
| 29 | #define An 31536000000 // Day x 365 | |
| 30 | #define Mois 2592000000 // Day x 30 | |
| 31 | #define Semaine 604800000 // Day x 7 | |
| 32 | #define Jour 86400000 // Hour x 24 | |
| 33 | #define Heure 3600000 // Minute x 60 | |
| 34 | #define Minute 60000 // Second x 60 | |
| 35 | #define Seconde 1000 // Millisecond x 1000 | |
| 36 | //-----------------------------------------------------------------[ Variables ] | |
| 37 | //--------------------------------------------------------------------[ Unused ] | |
| 38 | main() {}
| |
| 39 | //--------------------------------------------------------------------[ Timers ] | |
| 40 | //----------------------------------------------------------[ Custom Functions ] | |
| 41 | //---------------------------------------------------------[ Default Callbacks ] | |
| 42 | public OnGameModeInit() {
| |
| 43 | mysql_connect(mysql_host,mysql_user,mysql_database ,mysql_password); | |
| 44 | enum PlayerInfo | |
| 45 | {
| |
| 46 | Username[23], | |
| 47 | Password[24], | |
| 48 | Argent | |
| 49 | } | |
| 50 | new PInfo[MAX_PLAYERS][PlayerInfo]; | |
| 51 | return true; | |
| 52 | } | |
| 53 | ||
| 54 | public OnGameModeExit() {
| |
| 55 | return true; | |
| 56 | } | |
| 57 | ||
| 58 | public OnPlayerConnect(playerid) {
| |
| 59 | new Query[80],pName[24],string[164]; | |
| 60 | GetPlayerName(playerid,pName,24); | |
| 61 | format(Query,sizeof(Query),"SELECT `Username` FROM `Users` WHERE `Username` = '%s' LIMIT 1;",pName); | |
| 62 | mysql_query(Query); | |
| 63 | mysql_store_result(); | |
| 64 | if(mysql_num_rows() != 0)//if number of rows is different from 0 then continue | |
| 65 | {
| |
| 66 | format(string,sizeof(string),"Hey, %s! \nYour account is registered.\nPlease enter the password to log in!",pName); | |
| 67 | ShowPlayerDialog(playerid,0,DIALOG_STYLE_INPUT,"Lo g in",string,"Login",""); | |
| 68 | } | |
| 69 | else | |
| 70 | {
| |
| 71 | format(string,sizeof(string),"Hey, %s! \nYour account is not registered. \nPlease register to continue!",pName); | |
| 72 | ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Re gister",string,"Register",""); | |
| 73 | } | |
| 74 | mysql_free_result(); | |
| 75 | return true; | |
| 76 | } | |
| 77 | ||
| 78 | public OnPlayerDisconnect(playerid, reason) {
| |
| 79 | return true; | |
| 80 | } | |
| 81 | ||
| 82 | public OnPlayerRequestClass(playerid, classid) {
| |
| 83 | return true; | |
| 84 | } | |
| 85 | ||
| 86 | public OnPlayerRequestSpawn(playerid) {
| |
| 87 | return true; | |
| 88 | } | |
| 89 | ||
| 90 | public OnPlayerSpawn(playerid) {
| |
| 91 | return true; | |
| 92 | } | |
| 93 | ||
| 94 | public OnPlayerDeath(playerid, killerid, reason) {
| |
| 95 | return true; | |
| 96 | } | |
| 97 | ||
| 98 | public OnVehicleSpawn(vehicleid) {
| |
| 99 | return true; | |
| 100 | } | |
| 101 | ||
| 102 | public OnVehicleDeath(vehicleid, killerid) {
| |
| 103 | return true; | |
| 104 | } | |
| 105 | ||
| 106 | public OnPlayerText(playerid, text[]) {
| |
| 107 | return true; | |
| 108 | } | |
| 109 | ||
| 110 | public OnPlayerCommandText(playerid, cmdtext[]) {
| |
| 111 | OnPlayerText(playerid, cmdtext); | |
| 112 | return true; | |
| 113 | } | |
| 114 | ||
| 115 | public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) {
| |
| 116 | return true; | |
| 117 | } | |
| 118 | ||
| 119 | public OnPlayerExitVehicle(playerid, vehicleid) {
| |
| 120 | return true; | |
| 121 | } | |
| 122 | ||
| 123 | public OnPlayerStateChange(playerid, newstate, oldstate) {
| |
| 124 | return true; | |
| 125 | } | |
| 126 | ||
| 127 | public OnPlayerEnterCheckpoint(playerid) {
| |
| 128 | return true; | |
| 129 | } | |
| 130 | ||
| 131 | public OnPlayerLeaveCheckpoint(playerid) {
| |
| 132 | return true; | |
| 133 | } | |
| 134 | ||
| 135 | public OnPlayerEnterRaceCheckpoint(playerid) {
| |
| 136 | return true; | |
| 137 | } | |
| 138 | ||
| 139 | public OnPlayerLeaveRaceCheckpoint(playerid) {
| |
| 140 | return true; | |
| 141 | } | |
| 142 | ||
| 143 | public OnRconCommand(cmd[]) {
| |
| 144 | return true; | |
| 145 | } | |
| 146 | ||
| 147 | public OnObjectMoved(objectid) {
| |
| 148 | return true; | |
| 149 | } | |
| 150 | ||
| 151 | public OnPlayerObjectMoved(playerid, objectid) {
| |
| 152 | return true; | |
| 153 | } | |
| 154 | ||
| 155 | public OnPlayerPickUpPickup(playerid, pickupid) {
| |
| 156 | return true; | |
| 157 | } | |
| 158 | ||
| 159 | public OnVehicleMod(playerid, vehicleid, componentid) {
| |
| 160 | return true; | |
| 161 | } | |
| 162 | ||
| 163 | public OnEnterExitModShop(playerid, enterexit, interiorid) {
| |
| 164 | return true; | |
| 165 | } | |
| 166 | ||
| 167 | public OnVehiclePaintjob(playerid, vehicleid, paintjobid) {
| |
| 168 | return true; | |
| 169 | } | |
| 170 | ||
| 171 | public OnVehicleRespray(playerid, vehicleid, color1, color2) {
| |
| 172 | return true; | |
| 173 | } | |
| 174 | ||
| 175 | public OnVehicleDamageStatusUpdate(vehicleid, playerid) {
| |
| 176 | return true; | |
| 177 | } | |
| 178 | ||
| 179 | public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat) {
| |
| 180 | return true; | |
| 181 | } | |
| 182 | ||
| 183 | public OnPlayerSelectedMenuRow(playerid, row) {
| |
| 184 | return true; | |
| 185 | } | |
| 186 | ||
| 187 | public OnPlayerExitedMenu(playerid) {
| |
| 188 | return true; | |
| 189 | } | |
| 190 | ||
| 191 | public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid) {
| |
| 192 | return true; | |
| 193 | } | |
| 194 | ||
| 195 | public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
| |
| 196 | return true; | |
| 197 | } | |
| 198 | ||
| 199 | public OnRconLoginAttempt(ip[], password[], success ) {
| |
| 200 | return true; | |
| 201 | } | |
| 202 | ||
| 203 | public OnPlayerUpdate(playerid) {
| |
| 204 | return true; | |
| 205 | } | |
| 206 | ||
| 207 | public OnPlayerStreamIn(playerid, forplayerid) {
| |
| 208 | return true; | |
| 209 | } | |
| 210 | ||
| 211 | public OnPlayerStreamOut(playerid, forplayerid) {
| |
| 212 | return true; | |
| 213 | } | |
| 214 | ||
| 215 | public OnVehicleStreamIn(vehicleid, forplayerid) {
| |
| 216 | return true; | |
| 217 | } | |
| 218 | ||
| 219 | public OnVehicleStreamOut(vehicleid, forplayerid) {
| |
| 220 | return true; | |
| 221 | } | |
| 222 | ||
| 223 | public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
| |
| 224 | ||
| 225 | if(dialogid == Logindialog) | |
| 226 | {
| |
| 227 | if(strlen(inputtext) == 0) | |
| 228 | {
| |
| 229 | ShowPlayerDialog(playerid,Regdialog,DIALOG_STYLE_I NPUT,"Register - Entrez votre mdp","You are about to register a new account! \nChoississez un mdp \n","Register!",""); | |
| 230 | } | |
| 231 | else | |
| 232 | {
| |
| 233 | LoginPlayer(playerid,inputtext); | |
| 234 | } | |
| 235 | } | |
| 236 | return true; | |
| 237 | } | |
| 238 | ||
| 239 | public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid) {
| |
| 240 | return true; | |
| 241 | } | |
| 242 | ||
| 243 | public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid) {
| |
| 244 | return true; | |
| 245 | } | |
| 246 | ||
| 247 | public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ) {
| |
| 248 | return true; | |
| 249 | } | |
| 250 | ||
| 251 | public OnPlayerClickTextDraw(playerid, Text:clickedid) {
| |
| 252 | return true; | |
| 253 | } | |
| 254 | ||
| 255 | public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid) {
| |
| 256 | return true; | |
| 257 | } | |
| 258 | ||
| 259 | public OnPlayerClickPlayer(playerid, clickedplayerid, source) {
| |
| 260 | return true; | |
| 261 | } | |
| 262 | ||
| 263 | public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ ) {
| |
| 264 | return true; | |
| 265 | } | |
| 266 | ||
| 267 | public OnPlayerEditAttachedObject(playerid, response, index, modelid, boneid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:fRotZ, Float:fScaleX, Float:fScaleY, Float:fScaleZ ) {
| |
| 268 | return true; | |
| 269 | } | |
| 270 | ||
| 271 | public OnPlayerSelectObject(playerid, type, objectid, modelid, Float:fX, Float:fY, Float:fZ) {
| |
| 272 | return true; | |
| 273 | } | |
| 274 | ||
| 275 | ||
| 276 | ||
| 277 | ||
| 278 | ||
| 279 | ||
| 280 | stock LoginPlayer(playerid,const password[]) | |
| 281 | {
| |
| 282 | new EscapedText[60]; | |
| 283 | mysql_real_escape_string(password, EscapedText); | |
| 284 | format(Query,sizeof(Query),"SELECT * FROM `Users` WHERE `Username` = '%s' AND `Password` = '%s'",GetPName(playerid),EscapedText); | |
| 285 | mysql_query(Query); | |
| 286 | mysql_store_result(); | |
| 287 | if(mysql_num_rows() != 0) | |
| 288 | {
| |
| 289 | SendClientMessage(playerid,green,"You have been logged in!"); | |
| 290 | LoadStats(playerid); | |
| 291 | } | |
| 292 | else | |
| 293 | {
| |
| 294 | SendClientMessage(playerid,red,"Wrong password!"); | |
| 295 | Kick(playerid); | |
| 296 | } | |
| 297 | mysql_free_result(); | |
| 298 | return 1; | |
| 299 | } | |
| 300 | ||
| 301 | ||
| 302 | ||
| 303 | ||
| 304 | stock LoadStats(playerid) | |
| 305 | {
| |
| 306 | new pName[24],Query[80]; | |
| 307 | GetPlayerName(playerid,pName,24); | |
| 308 | format(Query, sizeof(Query), "SELECT * FROM `Users` WHERE `Username` = '%s' ", pName); | |
| 309 | mysql_query(Query); | |
| 310 | mysql_store_result(); | |
| 311 | mysql_fetch_row_format(Query, "|"); | |
| 312 | sscanf(Query, "e<p<|>s[24]s[23]i>", PInfo[playerid]); | |
| 313 | mysql_free_result(); | |
| 314 | GivePlayerMoney(playerid,PInfo[playerid][Money]); | |
| 315 | return 1; | |
| 316 | } |