SA-MP Forums Archive
How to do a command with Key? zcmd - 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: How to do a command with Key? zcmd (/showthread.php?tid=455270)



How to do a command with Key? zcmd - UserName31 - 01.08.2013

hey i want to use this command
PHP код:
cmd(flashplayeridparams[]) 
when i press the letter h on vehicle or just give me code ill find the keys, so when i press H the flash will turn on plz help

for example
PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
newkeys YOUR_KEY)
    {
        
OnPlayerCommandText("/refuel");
    }
    return 
true;

but with zcmd?


AW: How to do a command with Key? zcmd - CutX - 01.08.2013

Код:
if((newkeys & KEY_CTRL_BACK) && !(oldkeys & KEY_CTRL_BACK))
{
	//your code here
	return 1;
}



Re: AW: How to do a command with Key? zcmd - UserName31 - 01.08.2013

Quote:
Originally Posted by CutX
Посмотреть сообщение
Код:
if((newkeys & KEY_CTRL_BACK) && !(oldkeys & KEY_CTRL_BACK))
{
	//your code here
	return 1;
}
it dont work i just want CMD:flash to work but wont


AW: How to do a command with Key? zcmd - CutX - 01.08.2013

look, just put your code of "CMD:flash" where i wrote "your code here" - simple as that


Re: How to do a command with Key? zcmd - appleomax - 01.08.2013

I think it can't execute command like that
Код:
  if(newkeys & YOUR_KEY) 
    { 
        OnPlayerCommandText("/refuel"); 
    }
You need to type the code here from the command

Код:
if((newkeys & YOUR_KEY) && !(oldkeys & YOUR_KEY))
{
        //Code here
	return 1;
}



Re: How to do a command with Key? zcmd - UserName31 - 01.08.2013

Quote:
Originally Posted by appleomax
Посмотреть сообщение
I think it can't execute command like that
Код:
  if(newkeys & YOUR_KEY) 
    { 
        OnPlayerCommandText("/refuel"); 
    }
You need to type the code here from the command

Код:
if((newkeys & YOUR_KEY) && !(oldkeys & YOUR_KEY))
{
        //Code here
	return 1;
}
this what i put
PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if((
newkeys 262144) && !(oldkeys 262144))
    {
        
CMD:flash(playerid,params[])
    }
    return 
1;

with out no cmd on it will work perfect but when i add the cmd
PHP код:
CMD:flash(playerid,params[]) 
give me this

PHP код:
C:\Users\yahaira\Desktop\CNR 0.3X\gamemodes\1.2.pwn(1656) : error 029invalid expressionassumed zero
C
:\Users\yahaira\Desktop\CNR 0.3X\gamemodes\1.2.pwn(1656) : error 017undefined symbol "params"
C:\Users\yahaira\Desktop\CNR 0.3X\gamemodes\1.2.pwn(1656) : error 029invalid expressionassumed zero
C
:\Users\yahaira\Desktop\CNR 0.3X\gamemodes\1.2.pwn(1656) : fatal error 107too many error messages on one line
Compilation aborted
.Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
4 Errors




Re: How to do a command with Key? zcmd - Yashas - 01.08.2013

-_-
You need to call ZCMD funcs by "cmd_flash" though the CMD: way is correct.And just create a dummy variable new params[2]; and pass it to the function call arguments.


Re: How to do a command with Key? zcmd - RedJohn - 01.08.2013

Write your CMD:flash command here!


Re: How to do a command with Key? zcmd - Yashas - 01.08.2013

Change your code to this

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) 
{ 
    if((newkeys & 262144) && !(oldkeys & 262144)) 
    { 
        cmd_flash(playerid,params[]) ;
    } 
    return 1; 
}



Re: How to do a command with Key? zcmd - UserName31 - 01.08.2013

Quote:
Originally Posted by RedJohn
Посмотреть сообщение
Write your CMD:flash command here!
PHP код:
CMD:flash(playerid,params[])
{
 new 
vehicleid,panels,doors,lights,tires;
    
vehicleid GetPlayerVehicleID(playerid);
    if(!
Flasher[vehicleid]) {
        if (
GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
        {
            return 
SendClientMessage(playeridCOLOR_RED"* You are not the driver!");
        }
        if (!
GetVehicleModel(vehicleid)) return SendClientMessage(playeridCOLOR_RED"* You are not in a vehicle!");
        if (
IsValidObject(obj[vehicleid]) || IsValidObject(obj2[vehicleid]))
        {
            
DestroyObject(obj[vehicleid]), DestroyObject(obj2[vehicleid]);
            
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
            if(
LightPwr[vehicleid] == 1)
            
UpdateVehicleDamageStatus(vehicleidpanelsdoors0tires);
            else
            
UpdateVehicleDamageStatus(vehicleidpanelsdoors5tires);
            
Flasher[vehicleid] = 0;
        }
        switch (
GetVehicleModel(vehicleid))
        {
            case 
596:
            {
                
obj[vehicleid] = CreateObject(186460.00.00.00.00.00.0);
                
obj2[vehicleid] = CreateObject(186460.00.00.00.00.00.0);
                
AttachObjectToVehicle(obj[vehicleid], vehicleid0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000);
                
AttachObjectToVehicle(obj2[vehicleid], vehicleid, -0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000);
                
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
                
Flasher[vehicleid] = 1;
            }
            case 
597:
            {
                
obj[vehicleid] = CreateObject(186460.00.00.00.00.00.0);
                
obj2[vehicleid] = CreateObject(186460.00.00.00.00.00.0);
                
AttachObjectToVehicle(obj[vehicleid], vehicleid0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000);
                
AttachObjectToVehicle(obj2[vehicleid], vehicleid, -0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000);
                
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
                
Flasher[vehicleid] = 1;
            }
            case 
598:
            {
                
obj[vehicleid] = CreateObject(186460.00.00.00.00.00.0);
                
obj2[vehicleid] = CreateObject(186460.00.00.00.00.00.0);
                
AttachObjectToVehicle(obj[vehicleid], vehicleid0.524999, -0.3000000.8999990.0000000.0000000.000000);
                
AttachObjectToVehicle(obj2[vehicleid], vehicleid, -0.524999, -0.3000000.8999990.0000000.0000000.000000);
                
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
                
Flasher[vehicleid] = 1;
            }
            case 
599:
            {
                
obj[vehicleid] = CreateObject(186460.00.00.00.00.00.0);
                
obj2[vehicleid] = CreateObject(186460.00.00.00.00.00.0);
                
AttachObjectToVehicle(obj[vehicleid], vehicleid0.524999,0.000000,1.125000,0.000000,0.000000,0.000000);
                
AttachObjectToVehicle(obj2[vehicleid], vehicleid, -0.524999,0.000000,1.125000,0.000000,0.000000,0.000000);
                
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
                
Flasher[vehicleid] = 1;
            }
            case 
541://bullet
            
{
                
obj[vehicleid] = CreateObject(186460.00.00.00.00.00.0);
                
AttachObjectToVehicle(obj[vehicleid], vehicleid0.375000,0.524999,0.375000,0.000000,0.000000,0.000000);
                
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
                
Flasher[vehicleid] = 1;
            }
            case 
426://premier
            
{
                
obj[vehicleid] = CreateObject(186460.00.00.00.00.00.0);
                
AttachObjectToVehicle(obj[vehicleid], vehicleid0.524999,0.749999,0.375000,0.000000,0.000000,0.000000);
                
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
                
Flasher[vehicleid] = 1;
            }
            case 
427://enforcer
            
{
                
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
                
Flasher[vehicleid] = 1;
            }
            case 
416://Ambulance
            
{
                
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
                
Flasher[vehicleid] = 1;
            }
            case 
407://FireTruck
            
{
                
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
                
Flasher[vehicleid] = 1;
            }
            case 
560://sultan
            
{
                
obj[vehicleid] = CreateObject(186460.00.00.00.00.00.0);
                
AttachObjectToVehicle(obj[vehicleid], vehicleid0.225000,0.750000,0.449999,0.000000,0.000000,0.000000);
                
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
                
Flasher[vehicleid] = 1;
            }
            case 
490://FBI
            
{
                
obj[vehicleid] = CreateObject(186460.00.00.00.00.00.0);
                
AttachObjectToVehicle(obj[vehicleid], vehicleid0.000000,1.125000,0.599999,0.000000,0.000000,0.000000);
                
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
                
Flasher[vehicleid] = 1;
            }
            default:
            {
                return 
SendClientMessage(playerid, -1"You are not in a compatible police vehicle!");
            }
          }
        return 
SendClientMessage(playerid, -1"Flashed On ");
    } else {
        if (
IsValidObject(obj[vehicleid]) || IsValidObject(obj2[vehicleid])) {
            
DestroyObject(obj[vehicleid]), DestroyObject(obj2[vehicleid]);
        }
        
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
        if(
LightPwr[vehicleid] == 1)
            
UpdateVehicleDamageStatus(vehicleidpanelsdoors0tires);
        else
            
UpdateVehicleDamageStatus(vehicleidpanelsdoors5tires);
        
Flasher[vehicleid] = 0;
    }
    return 
1;