27.10.2016, 13:49
You use scanf to do this. There are other methods but in most cases you won't need to use them.
You should also use zcmd to make use of the "params[]" it offers.
Below is an example on how to use sscanf in ZCMD :
To check if a vehicle ID is valid you do this (inside the same callback you defined the sscanf variables):
Take a look at these wiki posts for more information (as you are using your specifiers incorrectly):
https://sampwiki.blast.hk/wiki/Control_Structures#Operators
https://sampwiki.blast.hk/wiki/Fast_Commands#Data_types
And the functions that do what you want to do:
https://sampwiki.blast.hk/wiki/IsValidVehicle
https://sampwiki.blast.hk/wiki/SetVehicleHealth
For your error, read the big yellow box at the "IsValidVehicle" wiki page.
You should also use zcmd to make use of the "params[]" it offers.
Below is an example on how to use sscanf in ZCMD :
PHP код:
// Define two variables for sscanf
new vehicleid, Float: vehiclehealth ;
// Store our data in the variables with sscanf using "params":
if ( sscanf ( params, "if", vehicle, vehiclehealth ) ) {
// If params are incorrect, return a error message here
}
PHP код:
if ( ! IsValidVehicleID ( vehicleid ) ) {
// If vehicle is not valid, return error message here
}
https://sampwiki.blast.hk/wiki/Control_Structures#Operators
https://sampwiki.blast.hk/wiki/Fast_Commands#Data_types
And the functions that do what you want to do:
https://sampwiki.blast.hk/wiki/IsValidVehicle
https://sampwiki.blast.hk/wiki/SetVehicleHealth
For your error, read the big yellow box at the "IsValidVehicle" wiki page.