Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

Command with an optional integer?

$
0
0
So I tried to make a command with the integer being optional, for example this:
PHP Code:

CMD:repair(playeridparams[])
{
    new 
caridmycarstring[128];
    
mycar GetPlayerVehicleID(playerid);
    if(
isnull(params))
    {
        if(
IsPlayerInAnyVehicle(playerid))
        {
            
RepairVehicle(mycar);
            
format(stringsizeof(string), "AdmWarn[%d]: %s repaired vehicle id %d."Player[playerid][AdminLevel], GetOOCName(playerid), mycar);
            
SendToAdmins(YELLOWstring0);
        }
    }
    else
    {
        
format(stringsizeof(string), "AdmWarn[%d]: %s repaired vehicle id %d."Player[playerid][AdminLevel], GetOOCName(playerid), carid);
        
SendToAdmins(YELLOWstring0);
        
RepairVehicle(carid);
    }
    return 
1;


First part works if you're in a vehicle but if you enter something after /repair, it sends the message but returns it as vehicle id 0. I'm assuming it's because I've got nothing set to define it?

I tried adding:
PHP Code:

if(sscanf(params"D(integer)"carid)) return SendClientMessage(playeridADM"SERVER: /repair [vehicleid] OR be in your car"); 

But it didn't work. I've never really done shit like this before so helps appreciated.

Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>