[HELP] Needed Fix -
Mr.Obscure - 25.08.2010
I Have this script, i need it to create a car, but i can't fix it.. i'm not good...
pawn Код:
if(strcmp(cmd, "/createcar", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if (PlayerInfo[playerid][pAdmin] < 4)
{
SendClientMessage(playerid, COLOR_GRAD1, "* Non sei autorizzato ad usare questo comando!");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USO: /createcar [carid] [prezzo] [color1] [color2]");
return 1;
}
new car;
car = strval(tmp);
if(car < 400 || car > 611) { SendClientMessage(playerid, COLOR_GREY, "* Il modello non deve essere < 400 o > 611 !"); return 1; }
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USO: /createcar [carid] [prezzo] [color1] [color2]");
return 1;
}
new prezzo;
prezzo = strval(tmp);
if(prezzo < 0 || prezzo > 1000000) { SendClientMessage(playerid, COLOR_GREY, " Prezzo < 0 o > 1.000.000$!"); return 1; }
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USO: /createcar [carid] [prezzo] [color1] [color2]");
return 1;
}
new color1;
color1 = strval(tmp);
if(color1 < 0 || color1 > 10000) { SendClientMessage(playerid, COLOR_GREY, " Color Number can't be below 0 or above 10000 !"); return 1; }
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USO: /createcar [carid] [prezzo] [color1] [color2]");
return 1;
}
new color2;
color2 = strval(tmp);
if(color2 < 0 || color2 > 10000) { SendClientMessage(playerid, COLOR_GREY, " Color Number can't be below 0 or above 10000 !"); return 1; }
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid, X,Y,Z);
new carid = CreateVehicle(car, X,Y,Z, 0.0, color1, color2, 60000);
format(string, sizeof(string), "** Veicolo numero %d creato! **", carid);
SendClientMessage(playerid, COLOR_LIGHTRED, string);
CarInfo[carid][cModel] = car;
CarInfo[carid][cColorOne] = color1;
CarInfo[carid][cColorTwo] = color2;
CarInfo[carid][cValue] = prezzo;
CarInfo[carid][cLocationx] = X;
CarInfo[carid][cLocationy] = Y;
CarInfo[carid][cLocationz] = Z;
CarInfo[carid][cOwned] = 0;
strmid(CarInfo[carid][cOwner], "Dealership", 0, strlen("Dealership"), 999);
strmid(CarInfo[carid][cTarga], "[STOCK]", 0, strlen("[STOCK]"), 999);
format(gstring, sizeof(gstring), "%s", VehicleNames[GetVehicleModel(carid)-400]);
strmid(CarInfo[carid][cDescription],gstring, 0, strlen(gstring), 999);
OnPropUpdate();
new rd = random(20000)+7500;
SBizzInfo[12][sbTill] -= CarInfo[carid][cValue];
SBizzInfo[12][sbTill] += rd;
}
return 1;
}
Re: [HELP] Needed Fix -
Pawno_Master - 25.08.2010
This should work:
Код:
if(strcmp(cmd, "/createcar", true) == 0)
{
if(!(PlayerInfo[playerid][pAdmin] < 4))
return SendClientMessage(playerid, 0xFF0000AA, "[Error]: You don't have permission to use this command!");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
return SendClientMessage(playerid, 0xFF0000AA, "[Error]: /createcar [vehicle name | vehicle ID] [color1] [color2] [respawnable]");
new car = ReturnVehicleModelID(tmp);
if(!car)
return SendClientMessage(playerid, 0xFF0000AA, "[Error]: Invalid vehicle name | vehicle ID.");
new color1, color2;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
color1 = -1;
color2 = -1;
}
else
{
color1 = strval(tmp);
if(color1 < -1 || color1 > 200)
return SendClientMessage(playerid, 0xFF0000AA "[Error]: Enter a valid color [0-200]");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) color2 = color1;
else color2 = strval(tmp);
if(color2 < -1 || color2 > 200)
return SendClientMessage(playerid, 0xFF0000AA, "[Error]: Enter a valid color [0-200]");
}
if(IsPlayerInAnyVehicle(playerid))
RemovePlayerFromVehicle(playerid);
new Float:X, Float:Y, Float:Z, Float:A;
GetPlayerPos(playerid, X,Y,Z);
GetPlayerFacingAngle(playerid,A);
new carid = CreateVehicle(car, X,Y,Z,A, color1, color2, -1);
tmp = strtok(cmdtext, idx);
PutPlayerInVehicle(playerid,carid,0);
LinkVehicleToInterior(carid,GetPlayerInterior(playerid));
for(new i = 0; i < sizeof(CreatedCars); i++)
{
if(CreatedCars[i] == INVALID_VEHICLE_ID)
{
CreatedCars[i] = carid;
break;
}
}
return 1;
}
Re: [HELP] Needed Fix -
Mr.Obscure - 25.08.2010
ok
the problem of mine code is: when i restart the GM the car has destroyed.
(it is for a RP server, is HC-RP based on LA-RP)
now testing..
Re: [HELP] Needed Fix -
Mr.Obscure - 25.08.2010
C:\Users\Administrator\Documents\Documenti Arcangelo\HC-RP\gamemodes\hcrp.pwn(28860) : error 017: undefined symbol "ReturnVehicleModelID"
C:\Users\Administrator\Documents\Documenti Arcangelo\HC-RP\gamemodes\hcrp.pwn(28875) : error 001: expected token: ",", but found "-string-"
C:\Users\Administrator\Documents\Documenti Arcangelo\HC-RP\gamemodes\hcrp.pwn(28875) : warning 215: expression has no effect
C:\Users\Administrator\Documents\Documenti Arcangelo\HC-RP\gamemodes\hcrp.pwn(28875) : error 001: expected token: ";", but found ")"
C:\Users\Administrator\Documents\Documenti Arcangelo\HC-RP\gamemodes\hcrp.pwn(28875) : error 029: invalid expression, assumed zero
C:\Users\Administrator\Documents\Documenti Arcangelo\HC-RP\gamemodes\hcrp.pwn(28875) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
5 Errors.
Re: [HELP] Needed Fix -
Pawno_Master - 25.08.2010
Код:
stock ReturnVehicleModelID(string[])
{
if(IsNumeric(string))
{
new id = strval(string);
if(id >= 400 && id <= 611)
{
return id;
}
}
for(new i = 0;i < sizeof(vehName);i++)
{
if(strfind(vehName[i],string,true) != -1)
{
return i + 400;
}
}
return 0;
}
Forgot this
Re: [HELP] Needed Fix -
Mr.Obscure - 25.08.2010
Код:
C:\Users\Administrator\Documents\Documenti Arcangelo\HC-RP\gamemodes\hcrp.pwn(28848) : error 029: invalid expression, assumed zero
C:\Users\Administrator\Documents\Documenti Arcangelo\HC-RP\gamemodes\hcrp.pwn(28848) : error 017: undefined symbol "ReturnVehicleModelID"
C:\Users\Administrator\Documents\Documenti Arcangelo\HC-RP\gamemodes\hcrp.pwn(28861) : error 017: undefined symbol "vehName"
C:\Users\Administrator\Documents\Documenti Arcangelo\HC-RP\gamemodes\hcrp.pwn(28861) : error 036: empty statement
C:\Users\Administrator\Documents\Documenti Arcangelo\HC-RP\gamemodes\hcrp.pwn(28861) : error 017: undefined symbol "i"
C:\Users\Administrator\Documents\Documenti Arcangelo\HC-RP\gamemodes\hcrp.pwn(28861) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
6 Errors.
Re: [HELP] Needed Fix -
Mr.Obscure - 25.08.2010
so, I upload the GM maybe it can help u and me D:
Re: [HELP] Needed Fix -
Mr.Obscure - 25.08.2010
I need it as soon as possible
Re: [HELP] Needed Fix -
Pawno_Master - 25.08.2010
Uhm, I don't have all your includes.
Re: [HELP] Needed Fix -
Mr.Obscure - 25.08.2010
Includes and Pawno includes:
Fixed, the problem was: a variable ( CarInfo )