sscanf small problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: sscanf small problem (
/showthread.php?tid=311288)
sscanf small problem -
fubar - 15.01.2012
Ok this is being a pain,i have just converted my vehicle script to zcmd and sscanf,but i have run into a problem with this command,so if you can show me the light,i will be happy
Ok here is what i have
Код:
CMD:callcar(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "!! You can't call your vehicle while your in a vehicle !!");
if(isnull(params)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /callcar [vehicleid]");
new tmp[128],Index; tmp = strtok(params,Index);
new Float:playerx,Float:playery,Float:playerz,Float:playera;
for(new i=1;i<MAX_VEHICLES;i++) {
if(OwnedVeh(i)==strval(tmp)) {
if(IsPlayerAdmin(playerid)) {
GetPlayerPos(playerid,playerx,playery,playerz);
GetPlayerFacingAngle(playerid,playera);
DestroyVehicle(i);
CreateVehicle(vInfo[OwnedVeh(i)][vModel],playerx,playery,playerz,playera,vInfo[OwnedVeh(i)][vColor1], vInfo[OwnedVeh(i)][vColor2],600000);
SetVehicleNumberPlate(i, vInfo[OwnedVeh(i)][vPlate]);
ChangeVehiclePaintjob(i, vInfo[OwnedVeh(i)][vPaintJ]);
for(new iMod = 0; iMod < MAX_VEH_MODS; ++iMod) {
if(vMods[i][iMod] > 0) {
AddVehicleComponent(i, vMods[i][iMod]);
}
}
SendClientMessage(playerid,COLOR_RED,"[ » ] Your vehicle has been teleported to you !");
PutPlayerInVehicle(playerid,i,0);
}
else if(strmatch(vInfo[OwnedVeh(i)][vOwner],pName(playerid))) {
if(GetPlayerMoney(playerid) < 100) return SendClientMessage(playerid, COLOR_RED, "[ » ] You dont have money to call your vehicle !");
GetPlayerPos(playerid,playerx,playery,playerz);
GetPlayerFacingAngle(playerid,playera);
DestroyVehicle(i);
CreateVehicle(vInfo[OwnedVeh(i)][vModel],playerx,playery,playerz,playera,vInfo[OwnedVeh(i)][vColor1], vInfo[OwnedVeh(i)][vColor2],600000);
SetVehicleNumberPlate(i, vInfo[OwnedVeh(i)][vPlate]);
ChangeVehiclePaintjob(i, vInfo[OwnedVeh(i)][vPaintJ]);
for(new iMod = 0; iMod < MAX_VEH_MODS; ++iMod) {
if(vMods[i][iMod] > 0) {
AddVehicleComponent(i, vMods[i][iMod]);
}
}
GivePlayerMoney(playerid,-100);
SendClientMessage(playerid,COLOR_GREY,"[ » ] Your vehicle has been teleported to you !");
SendClientMessage(playerid,COLOR_GREY,"[ » ] This has cost you $100 !");
PutPlayerInVehicle(playerid,i,0);
}
else {
SendClientMessage(playerid,COLOR_RED,"[ » ] This is not your vehicle !");
}
}
}
return 1;
}
Ok i started to change it to sscanf,but run into problems
Код:
CMD:callcar(playerid, params[])
{
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "!! You can't call your vehicle while your in a vehicle !!");
new calc[128],Float:playerx,Float:playery,Float:playerz,Float:playera;
if(sscanf(params, "i",calc)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /callcar [vehicleid]");
for(new i=1;i<MAX_VEHICLES;i++) {
if(OwnedVeh(i)==strval(calc)) {
Now im not sure what is wrong,but it throws a wobbly at me and tells me its not my car or if i change this line
Код:
if(OwnedVeh(i)==strval(calc)) {
to
Код:
if(strmatch(OwnedVeh(i),calc)) {
it freezes for about 30 seconds then dumps all my cars on me
Anyways cheers for any help given