Having some problems while developing a pick/drop system:
#1

Hello,

I'm trying to develop a pick/drop (drug) system.

I currently have these in my game-mode:
PHP код:
CMD:dropweedplayeridcmdtext[] ) {
    new 
Float:x,
        
Floaty,
        
Float:z,
        
amount,
        
model;
    
GetPlayerPos(playeridxyz);
    if(
sscanf(cmdtext"dd"modelamount))
        return 
SendClientMessage(playerid, -1"USAGE: /dropweed [model] [amount]");
    
CreateDrug(modelamountxyz);
    return 
1;
}
CMD:pickup playeridcmdtext[] ) {
    
PickupDrug(playerid);
    return 
1;
}
stock CreateDrug(DModelDAmountFloat:DXFloat:DYFloat:DZ) {
        for(new 
0sizeof(dInfo); i++) {
        
            if(
dInfo[i][X] == 0.0 && dInfo[i][Y] == 0.0 && dInfo[i][Z] == 0.0) {
            
                
dInfo[i][Model] = DModel;
                
dInfo[i][Amount] = DAmount;
                
dInfo[i][X] = DX;
                
dInfo[i][Y] = DY;
                
dInfo[i][Z] = DZ;
                
DrugObject[i] = CreateDynamicObject(DModelDXDYDZ 0.90.00.00.0, -1, -1, -150.050.0);
                return 
1;
            }
        }
        return 
1;
}
forward PickupDrug(playerid);
public 
PickupDrug(playerid){
    new 
zString[128];
    for(new 
0sizeof(dInfo); i++) {
    
        if(
IsPlayerInRangeOfPoint(playerid2.0dInfo[i][X], dInfo[i][Y], dInfo[i][Z])) {
            
dInfo[i][X] = 0.0;
            
dInfo[i][Y] = 0.0;
            
dInfo[i][Z] = 0.0;
            
dInfo[i][Amount] = 0;
            if(
dInfo[i][Model] == 1578) {
            
                
format(zStringsizeof(zString), "You picked up %d grams of weed."dInfo[i][Amount]);
                
SendClientMessage(playerid, -1zString);
                
pInfo[playerid][Weed] += dInfo[i][Amount];
                
DestroyDynamicObject(DrugObject[i]);
            }
            return 
1;
        }
    }
    return 
1;

My problem is that I go in game, I do /dropweed 1578 (model) 59 (amount) and I believe the object does create but I can't see it at all and when I do /pickup it says I picked up 0 grams of Weed and then the object disappears because if I do /pickup on the same spot it won't tell me again that I picked up 0 grams.

At first, it would create a invisible object and I don't remember what I modified and now it doesn't appear at all.

Is there any way of doing this much easier and more reliable?

Thank you!
Reply
#2

Now it won't say that you've picked 0 drugs.

Код:
forward PickupDrug(playerid); 
public PickupDrug(playerid){ 
    new zString[128]; 

    for(new i = 0; i < sizeof(dInfo); i++) { 
     

        if(IsPlayerInRangeOfPoint(playerid, 2.0, dInfo[i][X], dInfo[i][Y], dInfo[i][Z])) { 
            dInfo[i][X] = 0.0; 
            dInfo[i][Y] = 0.0; 
            dInfo[i][Z] = 0.0; 
            if(dInfo[i][Model] == 1578) { 
             
                format(zString, sizeof(zString), "You picked up %d grams of weed.", dInfo[i][Amount]); 
                SendClientMessage(playerid, -1, zString); 
                pInfo[playerid][Weed] += dInfo[i][Amount]; 
                DestroyDynamicObject(DrugObject[i]); 
                dInfo[i][Amount] = 0;
            } 
            return 1; 
        } 
    } 
    return 1; 
}
Reply
#3

I can't believe I did that mistake. Thank you! [+rep].

Now if you guys could tell me why the object creates but I can't see it.
Reply
#4

Well try this and let me know if now it appears.

Код:
DrugObject[i] = CreateDynamicObject(DModel, DX, DY, DZ - 0.9, 0.0, 0.0, 0.0);
Reply
#5

It works. All works now, thank you once again. I will +rep you again as soon as I can.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)