function returning value help +rep -
Shabi RoxX - 10.03.2012
Hi I guys I made this stock function.....
pawn Код:
stock SendAdminMessage(color,text[])
{
new File:file = fopen(Logs_AdmCmd,io_append),String[512],hour,mins,secs,year,month,day;
gettime(hour,mins,secs);
getdate(year,month,day);
format(String,sizeof(String),"[%d/%d/%d][%d:%d:%d] %s \n",day,month,year,hour,mins,secs,text);
fwrite(file,String);
fclose(file);
printf(String);
foreach(Player,i)
{
if(GetP_VarInt(i,p_Adminlevel) > 0)
{
SendClientMessage(i,color,text);
}
}
}
And a command in which am using it:
pawn Код:
CMD:deleteplayervehicle(playerid,params[])
{
new str[128],vehid;
if(GetP_VarInt(playerid,p_Adminlevel) > 4)
{
if(IsPlayerInPlayersVehicle(playerid))
{
vehid = GetPlayerVehicleID(playerid);
DestroyVehicle(vehid);
format(str,sizeof(str),"AdminCMD: Admin %s have deleted a player vehicle(%s).",GetPlayerNameEx(playerid),GetVehicleName(vehid));
SendAdminMessage(C_DARKRED2,str);
}
}
return 1;
}
But The problem is this function is not working and server show "server unknown command."
If I used Like this it works :
pawn Код:
format(str,sizeof(str),"AdminCMD: Admin %s have deleted a player vehicle(%s).",GetPlayerNameEx(playerid),GetVehicleName(vehid));
SendAdminMessage(C_DARKRED2,str);
DestroyVehicle(vehid);
and also works if i'll remove
Re: function returning value help +rep -
Shabi RoxX - 10.03.2012
Any one
?
Re: function returning value help +rep -
Twisted_Insane - 10.03.2012
What's your problem then? Simply use it in the way it works...
Re: function returning value help +rep -
Shabi RoxX - 10.03.2012
I Just want to known the logic...
Re: function returning value help +rep -
Konstantinos - 10.03.2012
It returns Uknown command because you destroyed the vehicle and then you sent the formatted message with
It can't get the name as the vehicle was already destroyed.
First format the message and send it with
SendAdminMessage and then destroy the vehicle.
Re: function returning value help +rep -
Shabi RoxX - 10.03.2012
But vehid is saved in integer
right ??
Re: function returning value help +rep -
Konstantinos - 10.03.2012
Yes, it stores the Vehicle ID, but for some reason it returns "SERVER: Unknown command." due to the vehicle id was destroyed.
Edit:
Although, don't use a value like 512 for only the date + text
128 is enough.
Re: function returning value help +rep -
Shabi RoxX - 10.03.2012
Thanks +rep