Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*-----------------------------------------------------/
- NOTE:
- Yes this only has 5 "functions", but don't worry, It's still beeing developed.
- This is like a, early early beta.
- |* GetOnlinePlayers()
- |- Returns amount of online players.
- |- Thanks to: Meller for scripting.
- |* AttachMapIconToPlayerForPlayer(playerid, targetid, iconid, icontype, color = 0)
- |- Name explains it.
- |- Thanks to: Meller for scripting.
- |- Thanks to: Manyula for idea.
- |* AttachMapIconToPlayerForAll(playerid, iconid, icontype, color = 0)
- |- Name explains it.
- |- Thanks to: Meller for scripting.
- |- Thanks to: Manyula for idea.
- |* OnVehicleUpdate(vehicleid)
- |- This calls everything a vehicle updates. (DOES NOT RUN ON POSITION OR VELOCITY)
- |- Thanks to: Meller for scripting.
- |* GetVehicleSpeed(vehicleid, meter[])
- |- Meter options: KM/H, MP/H
- |- Thanks to: Meller for scripting.
- /-----------------------------------------------------*/
- stock GetOnlinePlayers()
- {
- new OnlinePlayers = 0;
- for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
- if(IsPlayerConnected(playerid))
- OnlinePlayers++;
- return OnlinePlayers;
- }
- /*-----------------------------------------------------*/
- #include <YSI\y_hooks>
- new AttachedPlayerIcon[MAX_PLAYERS],
- AttachedPlayerIconID[MAX_PLAYERS],
- AttachedPlayerIconType[MAX_PLAYERS],
- AttachedPlayerIconColor[MAX_PLAYERS],
- AttachedPlayerIconTarget[MAX_PLAYERS],
- Float:AttachedPlayerIconLastPos[MAX_PLAYERS][4];
- hook OnPlayerConnect(playerid) { AttachedPlayerIcon[playerid] = 0; } // Only one is needed, because once we use Attach, we will re-set them.
- hook OnPlayerDisconnect(playerid, reason) { if(AttachedPlayerIcon[playerid] == 1) RemovePlayerMapIcon(AttachedPlayerIconTarget[playerid], AttachedPlayerIconID[playerid]); }
- stock AttachMapIconToPlayerForPlayer(playerid, targetid, iconid, icontype, color = 0)
- {
- if((IsPlayerConnected(playerid)) && (IsPlayerConnected(targetid)) && (iconid >= 0) && (iconid <= 100) && (icontype >= 0) && (icontype <= 63))
- {
- AttachedPlayerIcon[playerid] = 1;
- AttachedPlayerIconID[playerid] = iconid;
- AttachedPlayerIconType[playerid] = icontype;
- AttachedPlayerIconColor[playerid] = color;
- AttachedPlayerIconTarget[playerid] = targetid;
- GetPlayerPos(playerid, AttachedPlayerIconLastPos[playerid][1], AttachedPlayerIconLastPos[playerid][2], AttachedPlayerIconLastPos[playerid][3]);
- }
- }
- hook OnPlayerUpdate(playerid)
- {
- if(AttachedPlayerIcon[playerid] == 1)
- {
- new Float:PlayerPos[4];
- GetPlayerPos(playerid, PlayerPos[1], PlayerPos[2], PlayerPos[3]);
- if(PlayerPos[1] != AttachedPlayerIconLastPos[playerid][1])
- {
- RemovePlayerMapIcon(AttachedPlayerIconTarget[playerid], AttachedPlayerIconID[playerid]);
- SetPlayerMapIcon(AttachedPlayerIconTarget[playerid], AttachedPlayerIconID[playerid], PlayerPos[1], PlayerPos[2], PlayerPos[3], AttachedPlayerIconType[playerid], AttachedPlayerIconColor[playerid], MAPICON_GLOBAL);
- }
- else if(PlayerPos[2] != AttachedPlayerIconLastPos[playerid][2])
- {
- RemovePlayerMapIcon(AttachedPlayerIconTarget[playerid], AttachedPlayerIconID[playerid]);
- SetPlayerMapIcon(AttachedPlayerIconTarget[playerid], AttachedPlayerIconID[playerid], PlayerPos[1], PlayerPos[2], PlayerPos[3], AttachedPlayerIconType[playerid], AttachedPlayerIconColor[playerid], MAPICON_GLOBAL);
- }
- GetPlayerPos(playerid, AttachedPlayerIconLastPos[playerid][1], AttachedPlayerIconLastPos[playerid][2], AttachedPlayerIconLastPos[playerid][3]);
- }
- }
- /*-----------------------------------------------------*/
- #include <YSI\y_hooks>
- new AttachedPlayerIconEx[MAX_PLAYERS],
- AttachedPlayerIconIDEx[MAX_PLAYERS],
- AttachedPlayerIconTypeEx[MAX_PLAYERS],
- AttachedPlayerIconColorEx[MAX_PLAYERS],
- Float:AttachedPlayerIconLastPosEx[MAX_PLAYERS][4];
- hook OnPlayerConnect(playerid) { AttachedPlayerIconEx[playerid] = 0; }
- hook OnPlayerDisconnect(playerid, reason) { if(AttachedPlayerIconEx[playerid] == 1) for(new targetids = 0; targetids < MAX_PLAYERS; targetids++) if(IsPlayerConnected(targetids)) RemovePlayerMapIcon(targetids, AttachedPlayerIconIDEx[playerid]); }
- stock AttachMapIconToPlayerForAll(playerid, iconid, icontype, color = 0)
- {
- if((IsPlayerConnected(playerid)) && (iconid >= 0) && (iconid <= 100) && (icontype >= 0) && (icontype <= 63))
- {
- AttachedPlayerIconEx[playerid] = 1;
- AttachedPlayerIconIDEx[playerid] = iconid;
- AttachedPlayerIconTypeEx[playerid] = icontype;
- AttachedPlayerIconColorEx[playerid] = color;
- GetPlayerPos(playerid, AttachedPlayerIconLastPosEx[playerid][1], AttachedPlayerIconLastPosEx[playerid][2], AttachedPlayerIconLastPosEx[playerid][3]);
- }
- }
- hook OnPlayerUpdate(playerid)
- {
- if(AttachedPlayerIconEx[playerid] == 1)
- {
- new Float:PlayerPos[4];
- GetPlayerPos(playerid, PlayerPos[1], PlayerPos[2], PlayerPos[3]);
- if(PlayerPos[1] != AttachedPlayerIconLastPosEx[playerid][1])
- {
- for(new targetids = 0; targetids < MAX_PLAYERS; targetids++)
- {
- if(IsPlayerConnected(targetids))
- {
- RemovePlayerMapIcon(targetids, AttachedPlayerIconIDEx[playerid]);
- SetPlayerMapIcon(targetids, AttachedPlayerIconIDEx[playerid], PlayerPos[1], PlayerPos[2], PlayerPos[3], AttachedPlayerIconTypeEx[playerid], AttachedPlayerIconColorEx[playerid], MAPICON_GLOBAL);
- }
- }
- }
- else if(PlayerPos[2] != AttachedPlayerIconLastPosEx[playerid][2])
- {
- for(new targetids = 0; targetids < MAX_PLAYERS; targetids++)
- {
- if(IsPlayerConnected(targetids))
- {
- RemovePlayerMapIcon(targetids, AttachedPlayerIconIDEx[playerid]);
- SetPlayerMapIcon(targetids, AttachedPlayerIconIDEx[playerid], PlayerPos[1], PlayerPos[2], PlayerPos[3], AttachedPlayerIconTypeEx[playerid], AttachedPlayerIconColorEx[playerid], MAPICON_GLOBAL);
- }
- }
- }
- GetPlayerPos(playerid, AttachedPlayerIconLastPosEx[playerid][1], AttachedPlayerIconLastPosEx[playerid][2], AttachedPlayerIconLastPosEx[playerid][3]);
- }
- }
- /*-----------------------------------------------------*/
- #include <YSI\y_hooks>
- forward OnVehicleUpdate(vehicleid);
- hook OnVehicleDeath(vehicleid, killerid)
- {
- CallRemoteFunction("OnVehicleUpdate", "i", vehicleid);
- }
- hook OnVehicleSpawn(vehicleid)
- {
- CallRemoteFunction("OnVehicleUpdate", "i", vehicleid);
- }
- hook OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- CallRemoteFunction("OnVehicleUpdate", "i", vehicleid);
- }
- hook OnPlayerExitVehicle(playerid, vehicleid)
- {
- CallRemoteFunction("OnVehicleUpdate", "i", vehicleid);
- }
- hook OnVehicleDamageStatusUpdate(vehicleid, playerid)
- {
- CallRemoteFunction("OnVehicleUpdate", "i", vehicleid);
- }
- hook OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- CallRemoteFunction("OnVehicleUpdate", "i", vehicleid);
- }
- hook OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- CallRemoteFunction("OnVehicleUpdate", "i", vehicleid);
- }
- hook OnVehicleMod(playerid, vehicleid, componentid)
- {
- CallRemoteFunction("OnVehicleUpdate", "i", vehicleid);
- }
- hook OnTrailerUpdate(playerid, vehicleid)
- {
- CallRemoteFunction("OnVehicleUpdate", "i", vehicleid);
- }
- /*-----------------------------------------------------*/
- stock GetVehicleSpeed(vehicleid, meter[])
- {
- new Float:x,
- Float:y,
- Float:z,
- result;
- GetVehicleVelocity(vehicleid, x, y, z);
- if(!strcmp(meter, "KM/H"))
- result = floatround(floatsqroot(x*x + y*y + z*z) * 180);
- else
- result = floatround(floatsqroot(x*x + y*y + z*z) * 180 / 1.609344);
- return vel;
- }
- /*-----------------------------------------------------*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement