SA-MP Forums Archive
Question about this command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Question about this command (/showthread.php?tid=514155)



Question about this command - K9IsGodly - 20.05.2014

Hey guys, what's up? I have a little bit of a problem. I made this little /usecrack command a while ago, but upon testing it again, it works without having any crack. If you don't have any crack than it should just send you the message saying so, but it continues on to actually execute the command and get the player stoned. What is wrong?

PHP код:
CMD:usecrack(playeridparams[])
{
    if(
UseDrugsTimer[playerid]) return SendClientMessage(playerid,COLOR_GREY,"You must wait 5 seconds!");
    if(
PlayerCrackStoned[playerid] >= 2)
    {
        
SendClientMessage(playeridCOLOR_RED"You have used too much crack; therefore you have overdosed!");
        
SendClientMessage(playeridCOLOR_RED"You must seek medical attention or you will die!");
        
CrackDeathTimer[playerid] = SetTimerEx("Crackdeath"10000true"i"playerid);
    }
    if(
PlayerCrackStoned[playerid] >= 0)
    {
        
GameTextForPlayer(playerid"~p~You begin to feel~n~~g~ The crack high!"40006);
        
SetPlayerDrunkLevel(playerid15000);
        
SetPlayerWeather(playerid2009);
        if(!
IsPlayerInAnyVehicle(playerid)) { ApplyAnimation(playerid,"SMOKING","M_smk_drag",4.0,0,0,0,0,0); }
    }
    if(
PlayerDrugInfo[playerid][pCrack] >= 1)
    {
        new 
Float:armor;
        
GetPlayerArmour(playeridarmor);
        if(
armor 80) { SetPlayerArmour(playerid100.0); }
        else { 
SetPlayerArmour(playeridarmor 10.0); }
        
CrackFix[playerid] = SetTimerEx("CFixWeather"30000false"i"playerid);
        
SendClientMessage(playeridCOLOR_BLUE"You have used a gram of crack!");
        
UseDrugsTimer[playerid] = 1PlayerDrugInfo[playerid][pCrack] -= 1;
        
SetTimerEx("UseDrugs",5*1000,0,"i",playerid);
        return 
1;
    }
    else
    {
        
SendClientMessage(playeridCOLOR_RED"You don't have any crack left!");
    }
    return 
1;




Re: Question about this command - Nathan_Taylor - 20.05.2014

PHP код:
CMD:usecrack(playeridparams[]) 

    if(
PlayerDrugInfo[playerid][pCrack] = 0) return SendClientMessage(playeridCOLOR_RED"You don't have any crack left!"); 
    if(
UseDrugsTimer[playerid]) return SendClientMessage(playerid,COLOR_GREY,"You must wait 5 seconds!"); 
    if(
PlayerCrackStoned[playerid] >= 2
    { 
        
SendClientMessage(playeridCOLOR_RED"You have used too much crack; therefore you have overdosed!"); 
        
SendClientMessage(playeridCOLOR_RED"You must seek medical attention or you will die!"); 
        
CrackDeathTimer[playerid] = SetTimerEx("Crackdeath"10000true"i"playerid); 
    } 
    if(
PlayerCrackStoned[playerid] >= 0
    { 
        
GameTextForPlayer(playerid"~p~You begin to feel~n~~g~ The crack high!"40006); 
        
SetPlayerDrunkLevel(playerid15000); 
        
SetPlayerWeather(playerid2009); 
        if(!
IsPlayerInAnyVehicle(playerid)) { ApplyAnimation(playerid,"SMOKING","M_smk_drag",4.0,0,0,0,0,0); } 
    } 
    new 
Float:armor
    
GetPlayerArmour(playeridarmor); 
    if(
armor 80) { SetPlayerArmour(playerid100.0); } 
    else { 
SetPlayerArmour(playeridarmor 10.0); } 
    
CrackFix[playerid] = SetTimerEx("CFixWeather"30000false"i"playerid); 
    
SendClientMessage(playeridCOLOR_BLUE"You have used a gram of crack!"); 
    
UseDrugsTimer[playerid] = 1PlayerDrugInfo[playerid][pCrack] -= 1
    
SetTimerEx("UseDrugs",5*1000,0,"i",playerid);  
    return 
1

Moved a check to see if they have any crack on them to the top. And it returns a message if they have none which will end the command right there and not do anything else.


Re: Question about this command - K9IsGodly - 20.05.2014

Quote:
Originally Posted by Nathan_Taylor
Посмотреть сообщение
PHP код:
CMD:usecrack(playeridparams[]) 

    if(
PlayerDrugInfo[playerid][pCrack] = 0) return SendClientMessage(playeridCOLOR_RED"You don't have any crack left!"); 
    if(
UseDrugsTimer[playerid]) return SendClientMessage(playerid,COLOR_GREY,"You must wait 5 seconds!"); 
    if(
PlayerCrackStoned[playerid] >= 2
    { 
        
SendClientMessage(playeridCOLOR_RED"You have used too much crack; therefore you have overdosed!"); 
        
SendClientMessage(playeridCOLOR_RED"You must seek medical attention or you will die!"); 
        
CrackDeathTimer[playerid] = SetTimerEx("Crackdeath"10000true"i"playerid); 
    } 
    if(
PlayerCrackStoned[playerid] >= 0
    { 
        
GameTextForPlayer(playerid"~p~You begin to feel~n~~g~ The crack high!"40006); 
        
SetPlayerDrunkLevel(playerid15000); 
        
SetPlayerWeather(playerid2009); 
        if(!
IsPlayerInAnyVehicle(playerid)) { ApplyAnimation(playerid,"SMOKING","M_smk_drag",4.0,0,0,0,0,0); } 
    } 
    new 
Float:armor
    
GetPlayerArmour(playeridarmor); 
    if(
armor 80) { SetPlayerArmour(playerid100.0); } 
    else { 
SetPlayerArmour(playeridarmor 10.0); } 
    
CrackFix[playerid] = SetTimerEx("CFixWeather"30000false"i"playerid); 
    
SendClientMessage(playeridCOLOR_BLUE"You have used a gram of crack!"); 
    
UseDrugsTimer[playerid] = 1PlayerDrugInfo[playerid][pCrack] -= 1
    
SetTimerEx("UseDrugs",5*1000,0,"i",playerid);  
    return 
1

Moved a check to see if they have any crack on them to the top. And it returns a message if they have none which will end the command right there and not do anything else.
Thanks man, much appreciated.