SA-MP Forums Archive
How to detect a function - 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: How to detect a function (/showthread.php?tid=512942)



How to detect a function - Lidor124 - 13.05.2014

Hey,
How can i detect a player if he used any function, i mean if the function 'bla bla' is being used.
Example: how to detect if RepairVehicle(vehicleid) is used? i mean with if statements....

+REP


Re: How to detect a function - Madd92 - 13.05.2014

I don't get your problem... RepairVehicle is a script function, so a player can only use it trough the script. So why don't you look for the function in your code and implement your if-statement at those instances?

Edit: Ah ok, maybe you mean, how to conveniently do this, without finding every use of that function in the script?
Then just use this method: https://sampforum.blast.hk/showthread.php?tid=187195


Re: How to detect a function - iZN - 13.05.2014

You can probably make a player variable. Just do this:

pawn Код:
new repairedVehicle[MAX_PLAYERS]; // global (put this after the includes or defines w/e)

// OnPlayerConnect
repairedVehicle[playerid] = 0; // resetting the variable so that it may not set the previous playerid value

// Whenever you repair a vehicle, just simply set this variable to 1
RepairVehicle(vehicleid); // vehicle is repaired
repairedVehicle[playerid] = 1; // so we will set this to true/1 that the player have updated his vehicle

// Now if you wanted to check if the player vehicle is repaired
if(repairedVehicle[playerid] != 0)
{
    printf("playerid %i has already repaired his vehicle", playerid);
}
else
{
    printf("playerid %i did not repaired his vehicle yet", playerid);
}