12.12.2013, 04:21
what is wrong with the script, when i put /createfcar 411 0 0, the spawn color of the family car is random, help me to fix this.
Код:
if(strcmp(cmd, "/createfcar", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] < 7)
{
return SendClientMessage(playerid, COLOR_GREY," You're not authorized to use that command !");
}
new fvfam, fvcar, fvcol1, fvcol2;
tmp = strtok(cmdtext, idx);
fvfam = strvalEx(tmp);
tmp = strtok(cmdtext, idx);
if(fvfam < 1 || fvfam > 14 || !strlen(tmp))
{
return SendClientMessage(playerid, COLOR_GREY," USAGE: /createfcar [familyid] [car name/id] [color1] [color2]");
}
fvcar = ReturnVehicleModelID(tmp);
if(!fvcar)
{
return SendClientMessage(playerid, COLOR_GREY," USAGE: /createfcar [familyid] [car name/id] [color1] [color2]");
}
// new fvcol1, fvcol2;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
fvcol1 = -1;
fvcol2 = -1;
}
else
{
fvcol1 = strval(tmp);
if(fvcol1 < -1 || fvcol1 > 200)
return SendClientMessage(playerid, COLOR_GREY, " Enter a valid color [0-200]");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) fvcol2 = fvcol1;
else fvcol2 = strval(tmp);
if(fvcol2 < -1 || fvcol2 > 200)
return SendClientMessage(playerid, COLOR_GREY, " Enter a valid color [0-200]");
}
tmp = strtok(cmdtext, idx);
fvcol1 = strvalEx(tmp);
tmp = strtok(cmdtext, idx);
fvcol2 = strvalEx(tmp);
if(fvcol1 == 0) fvcol1 = -1;
if(fvcol2 == 0) fvcol2 = -1;
new Float:ffvX, Float:ffvY, Float:ffvZ, Float:ffvRot;
GetPlayerPos(playerid, ffvX, ffvY, ffvZ);
GetPlayerFacingAngle(playerid, ffvRot);
for(new fv=0;fv<MAX_FAMVEHICLES;fv++)
{
if(fv == MAX_FAMVEHICLES-1 && fVehicleInfo[fv][fvModel] != 0)
{
return SendClientMessage(playerid, COLOR_GREY," Server has reached limit for family cars !");
}
if(fVehicleInfo[fv][fvModel] != 0) continue;
fVehicleInfo[fv][fvX] = ffvX;
fVehicleInfo[fv][fvY] = ffvY;
fVehicleInfo[fv][fvZ] = ffvZ+1.5;
fVehicleInfo[fv][fvRot] = ffvRot;
fVehicleInfo[fv][fvModel] = fvcar;
fVehicleInfo[fv][fvFam] = fvfam-1;
fVehicleInfo[fv][fvCol1] = fvcol1;
fVehicleInfo[fv][fvCol2] = fvcol2;
fVehicleInfo[fv][fvLocked] = 1;
fVehicleInfo[fv][fvID] = CreateVehicle(fvcar, ffvX,ffvY,ffvZ,ffvRot,fvcol1,fvcol2,-1);
LockCar(fVehicleInfo[fv][fvID]);
PutPlayerInVehicle(playerid, fVehicleInfo[fv][fvID], 1);
break;
}
new fvstring[256];
format(fvstring,sizeof(fvstring)," Created family car for family '%s'", FamilyInfo[fvfam-1][FamilyName]);
SendClientMessage(playerid, COLOR_GREY, fvstring);
SaveFamVehicles();
return 1;
}


