21.08.2012, 15:29
Quote:
That's what the return values are for, read my posts again! I've added an example.
|
give me a error. symbol is never used: "playerid"
code:
pawn Код:
// in the command
if(isnull(params)) return SendClientMessage(playerid, -1, "usage /v name or id");
sscanf(params, "s[24]", temp_str);
new result = FormatSearchDialog(playerid, params);
if(result == -1) return SendClientMessage(playerid, -1, "the query is too short"); // Tell the user the query is too short
else if(result == 0) return SendClientMessage(playerid, -1, "no match was found"); // Tell the user no match was found
else if(400 <= result <= 611)
{
SendClientMessage(playerid, -1, "vehicle spawned");
GetPlayerPos(playerid, stat[0], stat[1], stat[2]), GetPlayerFacingAngle(playerid, stat[3]);
DestroyVehicle(user_vehicle[playerid]);
if(color[0] == -1) color[0] = random(125);
if(color[1] == -1) color[1] = random(125);
user_vehicle[playerid] = CreateVehicle(temp_id + 400, stat[0], stat[1], stat[2], stat[3], color[0], color[1], -1);
PutPlayerInVehicle(playerid, user_vehicle[playerid], 0);
}
// function
FormatSearchDialog(playerid, query[])
{
new id;
if(IsNumeric(query))
{
id = strval(query);
if(400 <= id <= 611)return id;
else if(0 <= id <= 211)return id+400;
}
else
{
if(strlen(query) < 2)return -1;
while(id < 212)
{
if(strfind(VehicleNames[id], query, true) != -1)
return id+400;
id++;
}
}
return 0;
}
// isnumeric
IsNumeric(text[])
{
for(new i, j = strlen(text); i < j; i++)
{
if(text[i] < '0' || text[i] > '9')
return 0;
}
return 1;
}