SetVehicleParamsEx Problem
#1

Hello,
I haven't written a carlock-system before, but now I need one and have quite a big problem.
When vehicles are loaded (out of .ini files) their variable "besitzer" (= owner) are set (either a number, which stands for an airline-id - or a name, which stands for a private owner). My problem at the moment is, that vehicles are not opened to anyone. Neither if I'm airline-member, nor if I'm the private owner of the vehicle.
pawn Код:
public OnVehicleStreamIn(vehicleid, forplayerid)
{
if(Autozeug[vehicleid][locked] == true)
{
new name[24];
GetPlayerName(forplayerid,name,24);
if(Spieler[forplayerid][airline] == Autozeug[vehicleid][besitzer] || !strcmp(name,Autozeug[vehicleid][besitzer])) SetVehicleParamsForPlayer(vehicleid,forplayerid,0,0);
else SetVehicleParamsForPlayer(vehicleid,forplayerid,0,1);
}
return 1;
}

// OnPlayerSpawn:
for(new i=0; i<MAX_VEHICLES; i++)
{
if(!strcmp(Autozeug[i][besitzer],name)) SetVehicleParamsForPlayer(i,playerid,0,0);
}
Then I've printed out OnVehicleStreamIn Autozeug[vehicleid][besitzer]. The result was the following:
Код:
[19:16:32] Owner: 2
[19:16:32] Owner: PdTrFeFeMkCoMyken
[19:16:32] Owner: FeMkCoMyken
[19:16:32] Owner: MkCoMyken
[19:16:32] Owner: CoMyken
I also printed out the owner on the carspawn, but everything was fine there.
So I wonder where these special characters come from. Also the true owner is a little bit mixed up with other player-names from the server (As you can see above)

I hope you can help me.

Regards
Padarom
Reply
#2

GetVehicleParamsEx before SetVehicleParamsEx.

https://sampwiki.blast.hk/wiki/SetVehicleParamsEx
Reply
#3

Oops I mistyped the title, but if you look at my code you see there is no SetVehicleParamsEx but SetVehicleParamsForPlayer - Thats what I wanted, gonna change the thread-title
Reply
#4

Theres a good example here:

https://sampwiki.blast.hk/wiki/SetVehicleParamsForPlayer
Reply
#5

Well I used this example for my /lock command, but I cannot figure out my newest bug. I got the lock-system to work with my company system, but cars which have private owners are now open for everybody and can be locked/unlocked by everybody. Hope you can help me:
pawn Код:
public OnVehicleStreamIn(vehicleid, forplayerid)
{
    if(Autozeug[vehicleid][locked] == true)
    {
        new name[24];
        GetPlayerName(forplayerid,name,24);
        if(Spieler[forplayerid][aktfirma] == strval(Autozeug[vehicleid][besitzer]) || !strcmp(name,Autozeug[vehicleid][besitzer])) SetVehicleParamsForPlayer(vehicleid,forplayerid,0,0); // aktfirma is the current company-id the player is logged into, besitzer is still the owner of a car (numeric: company-id, non-numeric/string: name of owner)
        else SetVehicleParamsForPlayer(vehicleid,forplayerid,0,1);
    }
    return 1;
}

// OnPlayerCommandText
    if(strcmp(cmdtext, "/lock", true) == 0)
    {
        if(GetPlayerVehicleSeat(playerid) != 0) return SendClientMessage(playerid, COLOR_TOMATO, "Du musst einen Wagen fahren.");
        new vehicleid = GetPlayerVehicleID(playerid), name[24];
        GetPlayerName(playerid,name,24);
        if(!strcmp(name,Autozeug[vehicleid][besitzer]) || Spieler[playerid][aktfirma] == strval(Autozeug[vehicleid][besitzer]))
        {
            if(Autozeug[vehicleid][locked] == false)
            {
                Autozeug[vehicleid][locked] = true;
                SendClientMessage(playerid, COLOR_WHITE, ColouredText("** Du hast dein Auto #FF6347abgeschlossen#FFFFFF."));
                for(new i=0;i<MAX_PLAYERS;i++)
                {
                    if(IsPlayerConnected(i))
                    {
                        if(i == playerid) continue;
                        if(IsNumeric(Autozeug[vehicleid][besitzer]) && Spieler[i][aktfirma] == strval(Autozeug[vehicleid][besitzer])) SetVehicleParamsForPlayer(vehicleid,i,0,0);
                        else SetVehicleParamsForPlayer(vehicleid,i,0,1);
                    }
                }
            }
            else
            {
                Autozeug[vehicleid][locked] = false;
                SendClientMessage(playerid, COLOR_WHITE, ColouredText("** Du hast dein Auto #33AA33aufgeschlossen#FFFFFF."));
                for(new i=0;i<MAX_PLAYERS;i++)
                {
                    if(IsPlayerConnected(i))
                    {
                        if(i == playerid) continue;
                        SetVehicleParamsForPlayer(vehicleid,i,0,0);
                    }
                }
            }
        }
        else SendClientMessage(playerid, COLOR_TOMATO, "Du bist nicht der Besitzer dieses Fahrzeuges.");
        return 1;
    }
Thanks
Padarom
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)