17.01.2013, 05:56
(
Последний раз редактировалось denNorske; 17.01.2013 в 07:43.
Причина: [SOLVED]
)
Hello all!
I was making myself a new command yesterday, when i noticed something strange, actually very strange. I dont know if i put anything wrong, but here is the code:
As you can see, i used a Variable named "veh" in the script, to get the player vehicle ID. I was having trouble with the code, so i started debugging the values if the "veh" and the "driver" were correct.
Suprisingly enough, the driver ID was correct, but the value for the "Veh" variable was 0 all the time, on everyone i tested. (They was in a car, i added a check in the code)
So, is this a bug, or did i put my variable the wrong way? Please explain if so.
Thanks.
-
I was making myself a new command yesterday, when i noticed something strange, actually very strange. I dont know if i put anything wrong, but here is the code:
pawn Код:
CMD:passenger (playerid,params[])
{
new driver;
new string123[165];
new veh = GetPlayerVehicleID(driver); // ------- Thats the Variable i used in PutPlayerInVehicle, to get vehicle ID...
if (PlayerInfo[playerid][aLevel] < 1)
return SendClientMessage(playerid, RED, "Only Administrators level 1+ can use this command");
if(sscanf(params, "i",driver))
return SendClientMessage(playerid, RED, "Hello Admin! Usage: "corange"/PASSENGER [Playerid]");
//Is he connected?
if(!IsPlayerConnected(driver))
return SendClientMessage(playerid, RED, "Player is not found.");
//Check if it is yourself
if(driver == playerid)
return SendClientMessage(playerid, RED, "You cant do this command on yourself!");
//Check if he is in vehicle
if(!IsPlayerInAnyVehicle(driver))
return SendClientMessage(playerid, RED, "Selected player is not in any vehicle.");
if((GetPlayerState(driver) == PLAYER_STATE_DRIVER) == false)
return SendClientMessage(playerid, RED, "Selected player is not the Vehicle driver.");
if(GetTeam{playerid} == CLASS_COPS ||GetTeam{playerid} == CLASS_CIA || GetTeam{playerid} == CLASS_FBI
&& GetTeam{driver} == CLASS_CIV && GetPlayerWantedLevel(driver) >=1)
return SendClientMessage(playerid, RED, "Selected Player is currently wanted, and you are a Cop. Function is Disabled, try again later (prevent abusing)");//Check if you are a cop AND that the entered player is wanted.
//If nothing of above stopped the admin from doing the command, below is the continuos script for the command. Spunky.
// put him in seat 1, passenger, in the drivers vehicle id
PutPlayerInVehicle(playerid, veh, 1); // Here it is
//DEBUGGING;
new string11[128];
new string111[128];
format(string11, sizeof(string11), "Variable veh = %d", veh);
SendClientMessageToAll(RED, string11);
format(string111, sizeof(string111), "Variable driver id = %d", driver);
SendClientMessageToAll(RED, string111);
//____________________________________________________________________
//If it didnt work correctly, this message will appear:
if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
return SendClientMessage(playerid, RED, "An error occured. Please contact the Scripter");
//successful:
else if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
{
format(string123, sizeof(string123), "You have now successfully entered the car as a passenger with player id %s", driver);
SendClientMessage(playerid, GREEN, string123);//message
}
return 1;
}
Suprisingly enough, the driver ID was correct, but the value for the "Veh" variable was 0 all the time, on everyone i tested. (They was in a car, i added a check in the code)
So, is this a bug, or did i put my variable the wrong way? Please explain if so.
Thanks.
-