08.12.2013, 15:59
(
Последний раз редактировалось marche123; 08.12.2013 в 16:59.
Причина: N/A
)
I am looking for save system for this license plate system
Код:
/* FS:Plate v3 Made by Marricio / Mecaurio. NOTE: When you change the plate the Z angle is modified that means it will work as 'flip' command too. */ #include a_samp #include zcmd #define DIALOG_PLATE 1000 new vehiclePlate[MAX_VEHICLES][128]; new szString[128]; stock StripText(text[]) { for(new i=0; i<strlen(text); i++) { if(text[i] == '(' && text[i+7] == ')') { text[i] = '{'; text[i+7] = '}'; } } return 1; } stock strreplace(_string[], const search[], const replacement[], bool:ignorecase = false, pos = 0, limit = -1, maxlength = sizeof (_string) ) { // No need to do anything if the limit is 0. if (limit == 0) return 0; new sublen = strlen(search), replen = strlen(replacement), bool:packed = ispacked(_string), maxlen = maxlength, len = strlen(_string), count = 0 ; // "maxlen" holds the max _string length (not to be confused with "maxlength", which holds the max. array size). // Since packed _strings hold 4 characters per array slot, we multiply "maxlen" by 4. if (packed) maxlen *= 4; // If the length of the sub_string is 0, we have nothing to look for.. if (!sublen) return 0; // In this line we both assign the return value from "strfind" to "pos" then check if it's -1. while (-1 != (pos = strfind(_string, search, ignorecase, pos))) { // Delete the _string we found strdel(_string, pos, pos + sublen); len -= sublen; // If there's anything to put as replacement, insert it. Make sure there's enough room first. if (replen && len + replen < maxlen) { strins(_string, replacement, pos, maxlength); pos += replen; len += replen; } // Is there a limit of number of replacements, if so, did we break it? if (limit != -1 && ++count >= limit) break; } return count; } CMD:plate( playerid, params[] ) { if( !IsPlayerInAnyVehicle( playerid ) ) return SendClientMessage( playerid, -1, "{c0c0c0}Error:{ffffff} You need to be in a vehicle." ); new dialogstring[600]; strcat( dialogstring, "{ffffff}Write in the text to be in the vehicle's plate\n\n{248eff}FORMAT TAGS:\n_______________________________________________________________________________\n\n" ); strcat( dialogstring, "{ffffff}(white) white text\n{F21D1D}(red) red text\n{1D5DF2}(blue) blue text\n{F2EB1D}(yellow) yellow text\n{DD1DF2}(purple) purple text\n{68C24F}(green) green text\n" ); strcat( dialogstring, "{ffffff}Or if you want to use hexadecimal numbers use the following format: (FFFFFF).\n\n{ff0000}Don't make the text too long!." ); ShowPlayerDialog( playerid, DIALOG_PLATE, DIALOG_STYLE_INPUT, "{ffffff}Write in the text to be displayed in the plate", dialogstring, "Set", "Cancel" ); return 1; } CMD:resetplate( playerid, params[] ) { if( isnull( params ) ) return SendClientMessage( playerid, -1, "{c0c0c0}Syntax:{ffffff} /resetplate [vehicleid]" ); if( !IsPlayerAdmin( playerid ) ) return SendClientMessage( playerid, -1, "{c0c0c0}Error:{ffffff} You're not an administrator." ); new Float:vehicle_pos[4], vehicleid = strval( params ); format( vehiclePlate[vehicleid], 128, "default" ); SetVehicleNumberPlate( vehicleid, "default" ); GetVehiclePos( vehicleid, vehicle_pos[0], vehicle_pos[1], vehicle_pos[2] ); GetVehicleZAngle( vehicleid, vehicle_pos[3] ); SetVehicleToRespawn( vehicleid ); SetVehiclePos( vehicleid, vehicle_pos[0], vehicle_pos[1], vehicle_pos[2] ); SetVehicleZAngle( vehicleid, vehicle_pos[3] ); return 1; } CMD:getplate( playerid, params[] ) { if( isnull( params ) ) return SendClientMessage( playerid, -1, "{c0c0c0}Syntax:{ffffff} /getplate [vehicleid]" ); format( szString, 128, "[VEHICLE ID: %d | PLATE: %s]", strval( params ), vehiclePlate[strval( params )] ); SendClientMessage( playerid, -1, szString ); return 1; } public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[] ) { if( dialogid == DIALOG_PLATE ) { if( !response ) return 1; new newplate[128]; format( newplate, 128, inputtext ); if( isnull( newplate ) ) { new dialogstring[600]; strcat( dialogstring, "{ffffff}Write in the text to be in the vehicle's plate\n\n{248eff}FORMAT TAGS:\n_______________________________________________________________________________\n\n" ); strcat( dialogstring, "{ffffff}(white) white text\n{F21D1D}(red) red text\n{1D5DF2}(blue) blue text\n{F2EB1D}(yellow) yellow text\n{DD1DF2}(purple) purple text\n{68C24F}(green) green text\n" ); strcat( dialogstring, "{ffffff}Or if you want to use hexadecimal numbers use the following format: (FFFFFF).\n\n{ff0000}Don't make the text too long! (excluding color formats)." ); ShowPlayerDialog( playerid, DIALOG_PLATE, DIALOG_STYLE_INPUT, "{ffffff}Write in the text to be displayed in the plate", dialogstring, "Set", "Cancel" ); return 1; } strreplace( newplate, "(white)", "{FFFFFF}", true ); strreplace( newplate, "(red)", "{F21D1D}", true ); strreplace( newplate, "(blue)", "{1D5DF2}", true ); strreplace( newplate, "(yellow)", "{F2EB1D}", true ); strreplace( newplate, "(purple)", "{DD1DF2}", true ); strreplace( newplate, "(green)", "{68C24F}", true ); StripText( newplate ); // This is to detect and fix hexadecimal numbers. new playervehicle, Float:vehicle_pos[4]; playervehicle = GetPlayerVehicleID( playerid ); format( vehiclePlate[playervehicle], 128, "%s", newplate ); SetVehicleNumberPlate( playervehicle, newplate ); GetPlayerPos( playerid, vehicle_pos[0], vehicle_pos[1], vehicle_pos[2] ); GetVehicleZAngle( playervehicle, vehicle_pos[3] ); SetVehicleToRespawn( playervehicle ); SetVehiclePos( playervehicle, vehicle_pos[0], vehicle_pos[1], vehicle_pos[2] ); SetVehicleZAngle( playervehicle, vehicle_pos[3] ); PutPlayerInVehicle( playerid, playervehicle, 0 ); format( szString, 128, "Your vehicle plate has succesfully changed to %s.", newplate ); SendClientMessage( playerid, -1, szString ); } return 1; }