Merge pull request #16 from dusan01/features/note-based-lvl5-6-cmds

Level 5 and 6 note based commands, replacecar and typos
This commit is contained in:
Lorenc Pekaj 2019-06-01 22:45:16 +10:00 committed by GitHub
commit 3d28606771
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 258 additions and 53 deletions

View File

@ -129,28 +129,68 @@ CMD:c( playerid, params[ ] )
CMD:creategarage( playerid, params[ ] )
{
new
cost, iTmp, iVehicle,
Float: X, Float: Y, Float: Z, Float: Angle
;
pID, cost;
if ( p_AdminLevel[ playerid ] < 5 ) return SendError( playerid, ADMIN_COMMAND_REJECT );
else if ( sscanf( params, "d", cost ) ) return SendUsage( playerid, "/creategarage [COST]" );
else if ( sscanf( params, "dU(-1)", cost, pID ) ) return SendUsage( playerid, "/creategarage [COST] [PLAYER_ID (optional)]" );
else if ( ! IsPlayerServerMaintainer( playerid ) && ! IsPlayerConnected( pID ) && cost < 50000 ) return SendError( playerid, "You must specify a player for garages under $50,000." );
else if ( cost < 100 ) return SendError( playerid, "The price must be located above 100 dollars." );
else if ( !( iVehicle = GetPlayerVehicleID( playerid ) ) ) return SendError( playerid, "You are not in any vehicle." );
else
{
AddAdminLogLineFormatted( "%s(%d) has created a garage", ReturnPlayerName( playerid ), playerid );
mysql_format(
dbHandle, szBigString, sizeof( szBigString ),
"SELECT * FROM `NOTES` WHERE (`NOTE` LIKE '{FFDC2E}V.I.P Garage%%' ) AND USER_ID=%d AND `DELETED` IS NULL LIMIT 0,1",
IsPlayerConnected( pID ) ? GetPlayerAccountID( pID ) : 0
);
mysql_tquery( dbHandle, szBigString, "OnAdminCreateGarage", "ddd", playerid, pID, cost );
}
return 1;
}
if ( GetVehiclePos( iVehicle, X, Y, Z ) && GetVehicleZAngle( iVehicle, Angle ) )
thread OnAdminCreateGarage( playerid, targetid, cost )
{
new
num_rows = cache_get_row_count( );
// if there is a note or the player is a maintainer
if ( IsPlayerServerMaintainer( playerid ) || num_rows || cost >= 50000 )
{
new
noteid = -1; // incase the lead maintainer makes it anyway
// remove the note if there is one
if ( num_rows )
{
if ( ( iTmp = CreateGarage( 0, cost, 0, X, Y, Z, Angle ) ) != -1 )
{
SaveToAdminLog( playerid, iTmp, "created garage" );
SendClientMessageFormatted( playerid, -1, ""COL_PINK"[GARAGE]"COL_WHITE" You have created a %s garage taking up garage id %d.", cash_format( cost ), iTmp );
}
else
SendClientMessage( playerid, -1, ""COL_PINK"[GARAGE]"COL_WHITE" Unable to create a garage due to a unexpected error." );
// get the first note
noteid = cache_get_field_content_int( 0, "ID", dbHandle );
// remove the note
SaveToAdminLog( playerid, noteid, "consumed player's note" );
mysql_single_query( sprintf( "UPDATE `NOTES` SET `DELETED`=%d WHERE `ID`=%d", GetPlayerAccountID( playerid ), noteid ) );
}
static
Float: X, Float: Y, Float: Z, Float: Angle, iVehicle, iTmp;
// proceed by creating the garage
if ( !( iVehicle = GetPlayerVehicleID( playerid ) ) ) return SendError( playerid, "You are not in any vehicle." );
if ( GetVehiclePos( iVehicle, X, Y, Z ) && GetVehicleZAngle( iVehicle, Angle ) && ( iTmp = CreateGarage( 0, cost, 0, X, Y, Z, Angle ) != -1 ) ) {
if ( IsPlayerConnected( targetid ) ) {
SaveToAdminLogFormatted( playerid, iTmp, "created garage (garage id %d) for %s (acc id %d, note id %d)", iTmp, ReturnPlayerName( targetid ), p_AccountID[ targetid ], noteid );
SendClientMessageFormatted( playerid, -1, ""COL_PINK"[GARAGE]"COL_WHITE" You have created a garage in the name of %s(%d).", ReturnPlayerName( targetid ), targetid );
AddAdminLogLineFormatted( "%s(%d) has created a garage for %s(%d)", ReturnPlayerName( playerid ), playerid, ReturnPlayerName( targetid ), targetid );
} else {
SaveToAdminLogFormatted( playerid, iTmp, "created garage (garage id %d)", iTmp );
SendClientMessageFormatted( playerid, -1, ""COL_PINK"[GARAGE]"COL_WHITE" You have created a garage." );
AddAdminLogLineFormatted( "%s(%d) has created a house", ReturnPlayerName( playerid ), playerid );
}
} else {
SendClientMessage( playerid, -1, ""COL_PINK"[GARAGE]"COL_WHITE" Unable to create a garage due to a unexpected error." );
}
}
else
{
SendError( playerid, "This user does not have a V.I.P Garage note." );
}
return 1;
}
@ -615,9 +655,7 @@ CMD:destroybribe( playerid, params[ ] )
CMD:createcar( playerid, params[ ] )
{
new
vName[ 24 ], pID,
Float: X, Float: Y, Float: Z, Float: Angle
;
vName[ 24 ], pID, iModel;
if ( p_AdminLevel[ playerid ] < 5 ) return SendError( playerid, ADMIN_COMMAND_REJECT );
else if ( sscanf( params, "us[24]", pID, vName ) ) return SendUsage( playerid, "/createcar [PLAYER_ID] [VEHICLE_NAME]" );
@ -625,27 +663,64 @@ CMD:createcar( playerid, params[ ] )
else if ( p_OwnedVehicles[ pID ] >= GetPlayerVehicleSlots( pID ) ) return SendError( playerid, "This player has too many vehicles." );
else
{
new
iModel, iTmp;
if ( ( iModel = GetVehicleModelFromName( vName ) ) != -1 ) {
AddAdminLogLineFormatted( "%s(%d) has created a vehicle for %s(%d)", ReturnPlayerName( playerid ), playerid, ReturnPlayerName( pID ), pID );
GetPlayerPos( playerid, X, Y, Z );
GetPlayerFacingAngle( playerid, Angle );
if ( ( iTmp = CreateBuyableVehicle( pID, iModel, 0, 0, X, Y, Z, Angle, 1337 ) ) != -1 ) {
SaveToAdminLogFormatted( playerid, iTmp, "created car (model id %d) for %s (acc id %d)", iModel, ReturnPlayerName( pID ), p_AccountID[ pID ] );
SendClientMessageFormatted( playerid, -1, ""COL_PINK"[VEHICLE]"COL_WHITE" You have created a vehicle in the name of %s(%d).", ReturnPlayerName( pID ), pID );
PutPlayerInVehicle( playerid, g_vehicleData[ pID ] [ iTmp ] [ E_VEHICLE_ID ], 0 );
}
else SendClientMessage( playerid, -1, ""COL_PINK"[VEHICLE]"COL_WHITE" Unable to create a vehicle due to a unexpected error." );
mysql_format(
dbHandle, szBigString, sizeof( szBigString ),
"SELECT * FROM `NOTES` WHERE (`NOTE` LIKE '{FFDC2E}V.I.P Vehicle%%' ) AND USER_ID=%d AND `DELETED` IS NULL LIMIT 0,1",
GetPlayerAccountID( pID )
);
mysql_tquery( dbHandle, szBigString, "OnAdminCreateVehicle", "ddd", playerid, pID, iModel );
}
else SendError( playerid, "Invalid Vehicle Model." );
}
return 1;
}
thread OnAdminCreateVehicle( playerid, targetid, modelid )
{
new
num_rows = cache_get_row_count( );
// if there is a note or the player is a maintainer
if ( IsPlayerServerMaintainer( playerid ) || num_rows )
{
new
noteid = -1; // incase the lead maintainer makes it anyway
// remove the note if there is one
if ( num_rows )
{
// get the first note
noteid = cache_get_field_content_int( 0, "ID", dbHandle );
// remove the note
SaveToAdminLog( playerid, noteid, "consumed player's note" );
mysql_single_query( sprintf( "UPDATE `NOTES` SET `DELETED`=%d WHERE `ID`=%d", GetPlayerAccountID( playerid ), noteid ) );
}
static
Float: X, Float: Y, Float: Z, Float: Angle, iTmp;
// proceed by creating the vehicle
GetPlayerPos( playerid, X, Y, Z );
GetPlayerFacingAngle( playerid, Angle );
if ( ( iTmp = CreateBuyableVehicle( targetid, modelid, 0, 0, X, Y, Z, Angle, 1337 ) ) != -1 ) {
SaveToAdminLogFormatted( playerid, iTmp, "created car (model id %d) for %s (acc id %d, note id %d)", modelid, ReturnPlayerName( targetid ), p_AccountID[ targetid ], noteid );
SendClientMessageFormatted( playerid, -1, ""COL_PINK"[VEHICLE]"COL_WHITE" You have created a vehicle in the name of %s(%d).", ReturnPlayerName( targetid ), targetid );
AddAdminLogLineFormatted( "%s(%d) has created a vehicle for %s(%d)", ReturnPlayerName( playerid ), playerid, ReturnPlayerName( targetid ), targetid );
PutPlayerInVehicle( playerid, g_vehicleData[ targetid ] [ iTmp ] [ E_VEHICLE_ID ], 0 );
} else {
SendClientMessage( playerid, -1, ""COL_PINK"[VEHICLE]"COL_WHITE" Unable to create a vehicle due to a unexpected error." );
}
}
else
{
SendError( playerid, "This user does not have a V.I.P Vehicle note." );
}
return 1;
}
CMD:destroycar( playerid, params[ ] )
{
new
@ -698,28 +773,117 @@ CMD:stripcarmods( playerid, params[ ] )
return 1;
}
CMD:replacecar( playerid, params[ ] )
{
new
vName[ 24 ], iModel;
if ( sscanf( params, "s[24]", vName ) ) return SendUsage(playerid, "/replacecar [VEHICLE_NAME]");
if ( p_AdminLevel[ playerid ] < 5 )
return SendError( playerid, ADMIN_COMMAND_REJECT );
if ( !IsPlayerInAnyVehicle( playerid ) )
return SendError( playerid, "You are not in any vehicle." );
if ( g_buyableVehicle{ GetPlayerVehicleID( playerid ) } == false )
return SendError( playerid, "This vehicle isn't a buyable vehicle." );
if ( ( iModel = GetVehicleModelFromName( vName ) ) != -1 ) {
new
oldmodel, ownerid, slotid, vehicleid = GetPlayerVehicleID( playerid ),
v = getVehicleSlotFromID( vehicleid, ownerid, slotid ),
Float: X, Float: Y, Float: Z, Float: Angle
;
if ( v == -1 ) return SendError( playerid, "This vehicle doesn't look like it can be replaced. (0xAA)" );
if ( g_vehicleData[ ownerid ] [ slotid ] [ E_CREATED ] == false ) return SendError( playerid, "This vehicle doesn't look like it can be replaced. (0xAF)" );
GetVehiclePos( vehicleid, X, Y, Z );
GetVehicleZAngle( vehicleid, Angle );
oldmodel = GetVehicleModel( vehicleid );
g_vehicleData[ ownerid ] [ slotid ] [ E_MODEL ] = iModel;
PutPlayerInVehicle( playerid, RespawnBuyableVehicle( vehicleid, playerid ), 0 );
SaveVehicleData( ownerid, slotid );
SendClientMessage( playerid, -1, ""COL_GREY"[VEHICLE]"COL_WHITE" You have replaced model of this vehicle via administration." );
SaveToAdminLogFormatted( playerid, slotid, "replaced car on %s (acc id %d, model id %d)", ReturnPlayerName( ownerid ), p_AccountID[ ownerid ], g_vehicleData[ ownerid ] [ slotid ] [ E_MODEL ] );
AddAdminLogLineFormatted( "%s(%d) changed %s(%d)'s vehicle from %s to %s", ReturnPlayerName( playerid ), playerid, ReturnPlayerName( ownerid ), ownerid, GetVehicleName( oldmodel ), GetVehicleName( iModel ) );
}
else
{
SendError( playerid, "Invalid Vehicle Model." );
}
return 1;
}
CMD:createhouse( playerid, params[ ] )
{
new
cost, iTmp,
Float: X, Float: Y, Float: Z
;
pID, cost;
if ( p_AdminLevel[ playerid ] < 5 ) return SendError( playerid, ADMIN_COMMAND_REJECT );
else if ( sscanf( params, "d", cost ) ) return SendUsage( playerid, "/createhouse [COST]" );
else if ( sscanf( params, "dU(-1)", cost, pID ) ) return SendUsage( playerid, "/createhouse [COST] [PLAYER_ID (optional)]" );
else if ( ! IsPlayerServerMaintainer( playerid ) && ! IsPlayerConnected( pID ) && cost < 50000 ) return SendError( playerid, "You must specify a player for homes under $50,000." );
else if ( cost < 100 ) return SendError( playerid, "The price must be located above 100 dollars." );
else
{
AddAdminLogLineFormatted( "%s(%d) has created a house", ReturnPlayerName( playerid ), playerid );
if ( GetPlayerPos( playerid, X, Y, Z ) )
mysql_format(
dbHandle, szBigString, sizeof( szBigString ),
"SELECT * FROM `NOTES` WHERE (`NOTE` LIKE '{FFDC2E}V.I.P House%%' ) AND USER_ID=%d AND `DELETED` IS NULL LIMIT 0,1",
IsPlayerConnected( pID ) ? GetPlayerAccountID( pID ) : 0
);
mysql_tquery( dbHandle, szBigString, "OnAdminCreateHouse", "ddd", playerid, pID, cost );
}
return 1;
}
thread OnAdminCreateHouse( playerid, targetid, cost )
{
new
num_rows = cache_get_row_count( );
// if there is a note or the player is a maintainer
if ( IsPlayerServerMaintainer( playerid ) || num_rows || cost >= 50000 )
{
new
noteid = -1; // incase the lead maintainer makes it anyway
// remove the note if there is one
if ( num_rows )
{
if ( ( iTmp = CreateHouse( "Home", cost, X, Y, Z ) ) != -1 )
{
SaveToAdminLogFormatted( playerid, iTmp, "created house for %s", cash_format( cost ) );
SendClientMessageFormatted( playerid, -1, ""COL_PINK"[HOUSE]"COL_WHITE" You have created a %s house taking up house id %d.", cash_format( cost ), iTmp );
}
else SendClientMessage( playerid, -1, ""COL_PINK"[HOUSE]"COL_WHITE" Unable to create a house due to a unexpected error." );
// get the first note
noteid = cache_get_field_content_int( 0, "ID", dbHandle );
// remove the note
SaveToAdminLog( playerid, noteid, "consumed player's note" );
mysql_single_query( sprintf( "UPDATE `NOTES` SET `DELETED`=%d WHERE `ID`=%d", GetPlayerAccountID( playerid ), noteid ) );
}
static
Float: X, Float: Y, Float: Z, iTmp;
// proceed by creating the house
if ( GetPlayerPos( playerid, X, Y, Z ) && ( iTmp = CreateHouse( "Home", cost, X, Y, Z ) ) != -1 ) {
if ( IsPlayerConnected( targetid ) ) {
SaveToAdminLogFormatted( playerid, iTmp, "created house (house id %d) for %s (acc id %d, note id %d)", iTmp, ReturnPlayerName( targetid ), p_AccountID[ targetid ], noteid );
SendClientMessageFormatted( playerid, -1, ""COL_PINK"[HOUSE]"COL_WHITE" You have created a house in the name of %s(%d).", ReturnPlayerName( targetid ), targetid );
AddAdminLogLineFormatted( "%s(%d) has created a house for %s(%d)", ReturnPlayerName( playerid ), playerid, ReturnPlayerName( targetid ), targetid );
} else {
SaveToAdminLogFormatted( playerid, iTmp, "created house (house id %d)", iTmp );
SendClientMessageFormatted( playerid, -1, ""COL_PINK"[HOUSE]"COL_WHITE" You have created a house." );
AddAdminLogLineFormatted( "%s(%d) has created a house", ReturnPlayerName( playerid ), playerid );
}
} else {
SendClientMessage( playerid, -1, ""COL_PINK"[HOUSE]"COL_WHITE" Unable to create a house due to a unexpected error." );
}
}
else
{
SendError( playerid, "This user does not have a V.I.P House note." );
}
return 1;
}

View File

@ -9,28 +9,69 @@
CMD:createbusiness( playerid, params[ ] )
{
new
Float: X, Float: Y, Float: Z, cost, type
;
pID, cost, type;
if ( p_AdminLevel[ playerid ] < 5 ) return SendError( playerid, ADMIN_COMMAND_REJECT );
else if ( sscanf( params, "dd", cost, type ) ) return SendUsage( playerid, "/createbusiness [COST] [TYPE]" );
else if ( sscanf( params, "ddU(-1)", cost, type, pID ) ) return SendUsage( playerid, "/createhouse [COST] [TYPE] [PLAYER_ID (optional)]" );
else if ( ! IsPlayerServerMaintainer( playerid ) && ! IsPlayerConnected( pID ) && cost < 50000 ) return SendError( playerid, "You must specify a player for business under $50,000." );
else if ( cost < 100 ) return SendError( playerid, "The price must be located above 100 dollars." );
else if ( ! ( 0 <= type <= 3 ) ) return SendError( playerid, "Invalid business type (Weed=0, Meth=1, Coke=2, Weapons=3)." );
else
{
GetPlayerPos( playerid, X, Y, Z );
AddAdminLogLineFormatted( "%s(%d) has created a business", ReturnPlayerName( playerid ), playerid );
mysql_format(
dbHandle, szBigString, sizeof( szBigString ),
"SELECT * FROM `NOTES` WHERE (`NOTE` LIKE '{FFDC2E}%%Business%%') AND USER_ID=%d AND `DELETED` IS NULL LIMIT 0,1",
IsPlayerConnected( pID ) ? GetPlayerAccountID( pID ) : 0
);
mysql_tquery( dbHandle, szBigString, "OnAdminCreateBusiness", "dddd", playerid, pID, cost, type );
}
return 1;
}
thread OnAdminCreateBusiness( playerid, targetid, cost, type )
{
new
num_rows = cache_get_row_count( );
// if there is a note or the player is a maintainer
if ( IsPlayerServerMaintainer( playerid ) || num_rows || cost >= 50000 )
{
new
iTmp = CreateBusiness( 0, "Business", cost, type, X, Y, Z );
noteid = -1; // incase the lead maintainer makes it anyway
if ( iTmp != ITER_NONE ) {
SaveToAdminLog( playerid, iTmp, "created business" );
SendClientMessageFormatted( playerid, -1, ""COL_PINK"[BUSINESS]"COL_WHITE" You have created a %s business taking up business id %d.", cash_format( cost ), iTmp );
} else {
// remove the note if there is one
if ( num_rows )
{
// get the first note
noteid = cache_get_field_content_int( 0, "ID", dbHandle );
// remove the note
SaveToAdminLog( playerid, noteid, "consumed player's note" );
mysql_single_query( sprintf( "UPDATE `NOTES` SET `DELETED`=%d WHERE `ID`=%d", GetPlayerAccountID( playerid ), noteid ) );
}
static
Float: X, Float: Y, Float: Z, iTmp;
// proceed by creating the business
if ( GetPlayerPos( playerid, X, Y, Z ) && ( iTmp = CreateBusiness( 0, "Business", cost, type, X, Y, Z ) != ITER_NONE ) ) {
if ( IsPlayerConnected( targetid ) ) {
SaveToAdminLogFormatted( playerid, iTmp, "created business (business id %d) for %s (acc id %d, note id %d)", iTmp, ReturnPlayerName( targetid ), p_AccountID[ targetid ], noteid );
SendClientMessageFormatted( playerid, -1, ""COL_PINK"[BUSINESS]"COL_WHITE" You have created a business in the name of %s(%d).", ReturnPlayerName( targetid ), targetid );
AddAdminLogLineFormatted( "%s(%d) has created a business for %s(%d)", ReturnPlayerName( playerid ), playerid, ReturnPlayerName( targetid ), targetid );
} else {
SaveToAdminLogFormatted( playerid, iTmp, "created business (business id %d)", iTmp );
SendClientMessageFormatted( playerid, -1, ""COL_PINK"[BUSINESS]"COL_WHITE" You have created a business." );
AddAdminLogLineFormatted( "%s(%d) has created a business", ReturnPlayerName( playerid ), playerid );
}
} else {
SendClientMessage( playerid, -1, ""COL_PINK"[BUSINESS]"COL_WHITE" Unable to create a business due to a unexpected error." );
}
}
else
{
SendError( playerid, "This user does not have a V.I.P Business note." );
}
return 1;
}