SA-MP Forums Archive
Veh command 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: Veh command problem (/showthread.php?tid=651500)



Veh command problem - Byonic - 21.03.2018

Hello,
Recently I have started adding factions on my server. Now this is going all fine, Im making steady progress, but one thing is really not making any sense to me.
PHP код:
CMD:veh(playeridparams[]) {
    new 
vehidcolor1color2;
    new 
admstring[256];
    if (
PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playeridCOLOR_LIGHTRED"Nu esti autorizat sa folosesti aceasta comanda!");
    if(
sscanf(params"iii"vehidcolor1color2)) return SendClientMessage(playeridCOLOR_LIGHTRED"Syntax: /veh <carid> <color 1> <color 2>");
    if (
vehid 400 || vehid 611) return SendClientMessage(playeridCOLOR_LIGHTRED"Invalid car id! [Car ID's range from 400 -> 611]");
    else
    {
        new 
Float:xFloat:yFloat:zFloat:ang;
        
GetPlayerPos(playeridxyz);
        
GetPlayerFacingAngle(playeridang);
        
vCar[playerid] = AddStaticVehicle(vehid3yzangcolor1color2);
        
PutPlayerInVehicle(playeridvCar[playerid], 0);
        
format(admstringsizeof(admstring), "AdmCMD: %s has spawned a %s (%d) (%d total cars)."GetName(playerid), VehicleNames[GetVehicleModel(GetPlayerVehicleID(playerid))-400], vehidvCar[playerid]);
    }
    
SMA(COLOR_LIGHTREDadmstring);
    return 
1;

That is my veh command, now the problem is when I spawn a vehicle the total cars shows 12, aka the 11 faction vehicles + my vehicle. All my faction vehicles are created in OnGamemodeInit using AddStaticVehicleEx...

Why are they mixing? By the way, when I use AddStaticVehicleEx I use newsv[1] = ... etc, so it shouldnt be mixing with vCar at all.


Re: Veh command problem - Jithu - 21.03.2018

i can help u i think


Re: Veh command problem - Byonic - 21.03.2018

Quote:
Originally Posted by Jithu
Посмотреть сообщение
i can help u i think
How?


Re: Veh command problem - ISmokezU - 21.03.2018

Could explain your problem more briefly?

PHP код:
CMD:veh(playeridparams[]) { 
    new 
Float:xFloat:yFloat:zFloat:ang;
    new 
admstring[144], vehidcolor1color2;  
    if (
PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playeridCOLOR_LIGHTRED"Nu esti autorizat sa folosesti aceasta comanda!"); 
    if(
sscanf(params"iii"vehidcolor1color2)) return SendClientMessage(playeridCOLOR_LIGHTRED"Syntax: /veh <carid> <color 1> <color 2>"); 
    if (
vehid 400 || vehid 611) return SendClientMessage(playeridCOLOR_LIGHTRED"Invalid car id! [Car ID's range from 400 -> 611]"); 
    
GetPlayerPos(playeridxyz); 
    
GetPlayerFacingAngle(playeridang); 
    
vCar[playerid] = CreateVehicle(vehid3yzangcolor1color2);
    
PutPlayerInVehicle(playeridvCar[playerid], 0); 
    
Printf("Vehicle ID: %i"vehid);
    
format(admstringsizeof(admstring), "AdmCMD: %s has spawned a %s (%d) (%d total cars)."GetName(playerid), VehicleNames[GetVehicleModel(GetPlayerVehicleID(playerid))-400], vehidvCar[playerid]); 
    
SMA(COLOR_LIGHTREDadmstring); 
    return 
1

I edited your command a bit try debugging it. See what vehicle ids are being outputted when you spawn a vehicle with this command.


Re: Veh command problem - Byonic - 21.03.2018

I fixed it already, the vCar var was causing issues.