Lock Marker
#1

Hey guyz i just want to know that how would i lock this marker from this command /lock Marker Image i need to know when i type this command the marker will lock and when i typed /unlock it will unlock when it's lock we can't go in the interior if we do un lock we can go in the inteior please me make this command for me
Reply
#2

Can anyone help me with that ?
Reply
#3

For that you simply create a variable
pawn Код:
// global
new bool: gLockHouse;
Than you create two simply commands
pawn Код:
CMD:lock(playerid, params[]) {
    #pragma unused params
    gLockHouse = true;
}

CMD:unlock(playerid, params[]) {
    #pragma unused params
    gLockHouse = false;
}
And at the end you only need to add at the enter exit code
pawn Код:
// code for entering the house
if(gLockHouse == false) { // house can only be entered if it isn't locked
     // CODE which already was there
}
Reply
#4

I want to lock the house marker so none can go in the house, How would i do this?
Reply
#5

Quote:
Originally Posted by Makhmoor
Посмотреть сообщение
I want to lock the house marker so none can go in the house, How would i do this?
PHP код:
/*
 * Example: house doors
 * ©  SA-MP Community
 */
#define MAX_HOUSES (1000)
enum E_HOUSES {
     
boolLOCKDOOR,
     
OWNERID,
     
ENTER_INTERIORID,
     
ENTER_WORLDID,
     
EXIT_INTERIORID,
     
EXIT_WORLDID,
     
FloatEXIT_X,
     
FloatEXIT_Y,
     
FloatEXIT_Z,     
     
FloatENTER_X,
     
FloatENTER_Y,
     
FloatENTER_Z
}
new 
houses[MAX_HOUSES][E_HOUSES];
enum E_P_INFO {
     
HOUSEID,
}
new 
p_info[MAX_PLAYERS][E_P_INFO];
/*
 * native SetPlayerHouseID(playerid, houseid);
 * native GetPlayerHouseID(playerid);
 * native SetHouseLock(houseid, bool:onlock);
 * native bool: GetHouseLock(houseid);
 */
#define SetPlayerHouseID(%1,%2) p_info[%1][HOUSEID]=%1
#define GetPlayerHouseID(%1)      p_info[%1][HOUSEID]
#define SetHouseLock(%1,%2)      houses[%1][LOCKDOOR]=%2
#define GetHouseLock(%1)           houses[%1][LOCKDOOR]
CMD:lock(playeridparams[]) {
     
#pragma unused params
     
new houseid GetPlayerHouseID(playerid);
     if (
houseid) {
          
SetHouseLock(houseidtrue);
     } else {
          
SendClientMessange(playerid, -1"You not inside house");
     }
     return 
true;
}
CMD:unlock(playeridparams[]) {
     
#pragma unused params
     
new houseid GetPlayerHouseID(playerid);
     if (
houseid) {
          
SetHouseLock(houseidfalse);
     } else {
          
SendClientMessange(playerid, -1"You not inside house");
     }
     return 
true;
}
CMD:enter(playeridparams[]) {
     
#pragma unused params
     
for (new iMAX_HOUSESi++) {       
            if (
IsPlayerInRangeOfPoint(playerid2.0houses[i][ENTER_X], houses[i][ENTER_Y], houses[i][ENTER_Z])) {  
                   if (!
GetHouseLock(i)) {
                   
SetPlayerHouseID(playeridi);
                   
houses[i][EXIT_INTERIORID] = GetPlayerInterior(playerid);
                   
houses[i][EXIT_WORLDID] = GetPlayerVirtualWorld(playerid);
                   
SetPlayerPos(playeridhouses[i][EXIT_X], houses[i][EXIT_Y], houses[i][EXIT_Z]);
                   
SetPlayerInterior(playeridhouses[i][ENTER_INTERIORID]); 
                   
SetPlayerVertualWorld(playeridhouses[i][ENTER_WORLDID]);
                   
SendClientMessange(playerid, -1"You entered in house");
                   break;
                   } else {
                   
SendClientMessange(playerid, -1"House is closed.");  
                   break;
                   }
            }
     }
     return 
true;
}
CMD:exit(playeridparams[]) {
     
#pragma unused params
     
for (new iMAX_HOUSESi++) {       
            if (
IsPlayerInRangeOfPoint(playerid2.0houses[i][EXIT_X], houses[i][EXIT_Y], houses[i][EXIT_Z])) {
                   
SetPlayerHouseID(playerid0);
                   
SetPlayerPos(playeridhouses[i][ENTER_X], houses[i][ENTER_Y], houses[i][ENTER_Z]);
                   
SetPlayerInterior(playeridhouses[i][EXIT_INTERIORID]); 
                   
SetPlayerVertualWorld(playeridhouses[i][EXIT_WORLDID]);
                   
SendClientMessange(playerid, -1"You exited of house");
                   break;
            }
     }
     return 
true;

NOTE: I have not tested this example can get out of Waring
Reply
#6

Extandet example:

PHP код:
/*
 * Example: house doors
 * ©  SA-MP Community
 */
#define MAX_HOUSES (1000)
enum E_HOUSES {
     
boolLOCKDOOR,
     
OWNERID,
     
ENTER_INTERIORID,
     
ENTER_WORLDID,
     
EXIT_INTERIORID,
     
EXIT_WORLDID,
     
FloatEXIT_X,
     
FloatEXIT_Y,
     
FloatEXIT_Z,     
     
FloatENTER_X,
     
FloatENTER_Y,
     
FloatENTER_Z
}
new 
houses[MAX_HOUSES][E_HOUSES];
enum E_P_INFO {
    
HOUSEID,
}
new 
p_info[MAX_PLAYERS][E_P_INFO];
/*
 * native SetPlayerHouseID(playerid, houseid);
 * native GetPlayerHouseID(playerid);
 * native SetHouseLock(houseid, bool:onlock);
 * native IsHouseLocked(houseid);
 * native SetHousePosEnter(houseid, Float:x, Float:y, Float:z, interiorid, worldid);
 * native SetHousePosExit(houseid, Float:x, Float:y, Float:z, interiorid, worldid);
 */
#define SetPlayerHouseID(%1,%2)             p_info[%1][HOUSEID]=%1
#define GetPlayerHouseID(%1)                p_info[%1][HOUSEID]
#define SetHouseLock(%1,%2)                 houses[%1][LOCKDOOR]=%2
#define IsHouseLocked(%1)                   (houses[%1][LOCKDOOR])
#define SetHousePosEnter(%1,%2,%3,%4,%5,%6) houses[%1][ENTER_X]=%2; houses[%1][ENTER_Y]=%3; houses[%1][ENTER_Z]=%4; houses[%1][ENTER_INTERIORID]=%5; houses[%1][ENTER_WORLDID]=%6
#define SetHousePosExit(%1,%2,%3,%4,%5,%6)  houses[%1][EXIT_X]=%2; houses[%1][EXIT_Y]=%3; houses[%1][EXIT_Z]=%4; houses[%1][EXIT_INTERIORID]=%5; houses[%1][EXIT_WORLDID]=%6
public OnGameModeInit() {
    
// <- Here will be your houses from a database loader
    //    His write yourself: SQLite or MySQL   
    //    NOTE: On loading used array 'houses'
    
return true;
}
CMD:lock(playeridparams[]) {
    
#pragma unused params
    
new houseid GetPlayerHouseID(playerid);
    if (
houseid) {
        
SetHouseLock(houseidtrue);
    } else {
        
SendClientMessange(playerid, -1"You not inside house");
    }
    return 
true;
}
CMD:unlock(playeridparams[]) {
    
#pragma unused params
    
new houseid GetPlayerHouseID(playerid);
    if (
houseid) {
        
SetHouseLock(houseidfalse);
    } else {
        
SendClientMessange(playerid, -1"You not inside house");
    }
    return 
true;
}
CMD:enter(playeridparams[]) {
    
#pragma unused params
    
for (new iMAX_HOUSESi++) {       
        if (
IsPlayerInRangeOfPoint(playerid2.0houses[i][ENTER_X], houses[i][ENTER_Y], houses[i][ENTER_Z])) {  
            if (!
IsHouseLocked(i)) {
                
SetPlayerHouseID(playeridi+1);
                
houses[i][EXIT_INTERIORID] = GetPlayerInterior(playerid);
                
houses[i][EXIT_WORLDID] = GetPlayerVirtualWorld(playerid);
                
SetPlayerPos(playeridhouses[i][EXIT_X], houses[i][EXIT_Y], houses[i][EXIT_Z]);
                
SetPlayerInterior(playeridhouses[i][ENTER_INTERIORID]); 
                
SetPlayerVertualWorld(playeridhouses[i][ENTER_WORLDID]);
                
SendClientMessange(playerid, -1"You entered in house");
                break;
            } else {
                
SendClientMessange(playerid, -1"House is closed.");  
                break;
            }
        }
    }
    return 
true;
}
CMD:exit(playeridparams[]) {
    
#pragma unused params
    
for (new iMAX_HOUSESi++) {       
         if (
IsPlayerInRangeOfPoint(playerid2.0houses[i][EXIT_X], houses[i][EXIT_Y], houses[i][EXIT_Z])) {
              
SetPlayerHouseID(playerid0);
              
SetPlayerPos(playeridhouses[i][ENTER_X], houses[i][ENTER_Y], houses[i][ENTER_Z]);
              
SetPlayerInterior(playeridhouses[i][EXIT_INTERIORID]); 
              
SetPlayerVertualWorld(playeridhouses[i][EXIT_WORLDID]);
              
SendClientMessange(playerid, -1"You exited of house");
              break;
         }
    }
    return 
true;
}
CMD:makeexit(playeridparams[]) {
    new 
          
houseid
    
;
    if (
sscanf(params"i"houseid)) {
          
format(msgsizeof(msg), "Invalid cmd. Use: /makeexit [houseid:0-%d]"houseidMAX_HOUSES-1);
          
SendClientMessange(playerid, -1msg);
          return 
true;
    }
    new
        
Floatx,
        
Floaty,
        
Floatz
    
;
    
GetPlayerPos(playeridxyz);
    
SetHousePosExit(houseidxyzGetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid));
    new 
          
msg[128]
    ;
    
format(msgsizeof(msg), "You maked <exit> house id %d"houseid);
    
SendClientMessange(playerid, -1msg);
    return 
true;
}
CMD:makeenter(playeridparams[]) {
    new 
          
houseid
    
;
    if (
sscanf(params"i"houseid)) {
          
format(msgsizeof(msg), "Invalid cmd. Use: /makeenter [houseid:0-%d]"houseidMAX_HOUSES-1);
          
SendClientMessange(playerid, -1msg);
          return 
true;
    }
    new
        
Floatx,
        
Floaty,
        
Floatz
    
;
    
GetPlayerPos(playeridxyz);
    
SetHousePosEnter(houseidxyzGetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid));
    new 
          
msg[128]
    ;
    
format(msgsizeof(msg), "You maked <enter> house id %d"houseid);
    
SendClientMessange(playerid, -1msg);
    return 
true;

NOTE: I have not tested this example can get out of Waring
Reply
#7

Look this image i want to make command like this if the house is locked i can't go inside the house how can i make this command /lockhouse and /unlockhouse
Reply
#8

Quote:
Originally Posted by Makhmoor
Посмотреть сообщение
Look this image i want to make command like this if the house is locked i can't go inside the house how can i make this command /lockhouse and /unlockhouse
Can anyone help me??
Reply
#9

Quote:
Originally Posted by Makhmoor
Посмотреть сообщение
Can anyone help me??
??
Reply
#10

Quote:
Originally Posted by Makhmoor
Посмотреть сообщение
??
I gave an example http://forum.sa-mp.com/showpost.php?...05&postcount=6

That is an option which you asked:
PHP код:
CMD:lock(playeridparams[]) {
    
#pragma unused params
    
for (new houseidhouseid MAX_HOUSEShouseid++) {   
        if (
IsPlayerInRangeOfPoint(playerid2.0houses[houseid][ENTER_X], houses[houseid][ENTER_Y], houses[houseid][ENTER_Z]
        || 
IsPlayerInRangeOfPoint(playerid2.0houses[houseid][EXIT_X], houses[houseid][EXIT_Y], houses[houseid][EXIT_Z])) {
        ) { 
            
SetHouseLock(houseidtrue);
            
SendClientMessange(playerid, -1"You closed door");
            return 
true;    
        }
    }
    
SendClientMessange(playerid, -1"To close door to go to her");
    return 
true;
}
CMD:unlock(playeridparams[]) {
    
#pragma unused params
    
for (new houseidhouseid MAX_HOUSEShouseid++) {   
        if (
IsPlayerInRangeOfPoint(playerid2.0houses[houseid][ENTER_X], houses[houseid][ENTER_Y], houses[houseid][ENTER_Z]
        || 
IsPlayerInRangeOfPoint(playerid2.0houses[houseid][EXIT_X], houses[houseid][EXIT_Y], houses[houseid][EXIT_Z])) {
        ) { 
            
SetHouseLock(houseidfalse);
            
SendClientMessange(playerid, -1"You opened door");
            return 
true;    
        }
    }
    
SendClientMessange(playerid, -1"To open door to go to her");
    return 
true;

Optimization code:

PHP код:
CMD:lock(playeridparams[]) {
    
#pragma unused params
    
for (new houseidhouseid MAX_HOUSEShouseid++) {   
        if (
IsPlayerInRangeOfPoint(playerid2.0houses[houseid][ENTER_X], houses[houseid][ENTER_Y], houses[houseid][ENTER_Z]
        || 
IsPlayerInRangeOfPoint(playerid2.0houses[houseid][EXIT_X], houses[houseid][EXIT_Y], houses[houseid][EXIT_Z])) {
        ) { 
            new
                
msg[128]
            ;
            if (
IsHouseLocked(houseid)) {
                
SetHouseLock(houseidfalse);
                
format(msgsizeof(msg), "You opened door in house #%d"houseid);
                
SendClientMessange(playerid, -1msg); 
            } else {
                
SetHouseLock(houseidtrue);
                
format(msgsizeof(msg), "You close door in house #%d"houseid);
                
SendClientMessange(playerid, -1msg);      
            }
            return 
true
        }
    }
    
SendClientMessange(playerid, -1"To open/close door to go to her");
    return 
true;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)