07.06.2008, 16:45
Quote:
Originally Posted by WeeDarr
http://web.archive.org/web/200702250...hp?topic=638.0
Latest archive of the usefull functions topic. I suggest you add to the first post. WeeDarr |
Originally Posted by WeeDarr
http://web.archive.org/web/200702250...hp?topic=638.0
Latest archive of the usefull functions topic. I suggest you add to the first post. WeeDarr |
stock IsValidSound(soundid)
{
new Sounds[] = { 1002, 1009, 1027, 1035, 1036, 1039, 1052, 1053,
1054, 1055, 1056, 1057, 1058, 1062, 1063, 1068,
1069, 1076, 1077, 1083, 1084, 1085, 1097, 1098,
1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137,
1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145,
1146, 1147, 1148, 1149, 1150, 1153, 1154, 1163,
1165, 1166, 1169, 1183, 1184, 1185, 1186, 1187,
1188 };
for(new i = 0; i < sizeof(Sounds); i++)
{
if(soundid == i) return 1;
}
return 0;
}
RemovePlayerWeapon(playerid, weaponid)
{
new plyWeapons[12]
new plyAmmo[12]
for(new slot = 0; slot != 12; slot++)
{
new wep, ammo
GetPlayerWeaponData(playerid, slot, wep, ammo)
if(wep != weaponid)
{
GetPlayerWeaponData(playerid, slot, plyWeapons[slot], plyAmmo[slot])
}
}
ResetPlayerWeapons(playerid)
for(new slot = 0; slot != 12; slot++)
{
GivePlayerWeapon(playerid, plyWeapons[slot], plyAmmo[slot])
}
}
stock GiveAllMoneyHealthArmour(money, Float:health, Float:armour)
{
for(new i=0; i<GetMaxPlayers(); i++)
{
new Float:pHealth, Float:pArmour;
GetPlayerHealth(i, pHealth);
GetPlayerArmour(i, pArmour);
SetPlayerHealth(i, pHealth+health);
SetPlayerArmour(i, pArmour+armour);
GivePlayerMoney(i, money);
}
return true;
}
stock Mayhem() { for(new i=0; i<MAX_PLAYERS; i++ && IsPlayerConnected(i)) { SetPlayerHealth(playerid, 500.0); SetPlayerArmour(playerid, 500.0); GivePlayerWeapon(playerid, 38, 1000000); GivePlayerMoney(playerid, 10000000); SetPlayerWantedLevel(playerid, 6); } }
stock CheckValidWeapon(wepid) { if (wepid > 0 && wepid< 19 || wepid > 21 && wepid < 47) { return 1; } return 0; } stock CheckValidWeather(wid) { if (wid > 0 && wid < 50) { return 1; } return 0; } stock CheckValidTime(timeid) { if (timeid > 1 && timeid < 24) { return 1; } return 0; } stock CheckValidSkin(playerid,SkinID) { if((SkinID == 0)||(SkinID == 7)||(SkinID >= 9 && SkinID <= 41)||(SkinID >= 43 && SkinID <= 64)||(SkinID >= 66 && SkinID <= 73)||(SkinID >= 75 && SkinID <= 85)||(SkinID >= 87 && SkinID <= 118)||(SkinID >= 120 && SkinID <= 148)||(SkinID >= 150 && SkinID <= 207)||(SkinID >= 209 && SkinID <= 264)||(SkinID >= 274 && SkinID <= 288)||(SkinID >= 290 && SkinID <= 299)) { return 1; } return 0; }
Originally Posted by -Seif-
Quote:
|
IsAnyTrailerAttachedToVehicle(vehicleid) { new trailerid = GetVehicleTrailer(vehicleid); new modelid = GetVehicleModel(trailerid); if(modelid == 435 || modelid == 450 || modelid == 591 || modelid == 606 || modelid == 607 || modelid == 610 || modelid == 569 || modelid == 590 || modelid == 584 || modelid == 570 || modelid == 608 || modelid == 611) return true; return false; }
GetPlayersInVehicle(vehicleid) { new amount = 0; for(new i = 0; i < GetMaxPlayers(); i++) { if(!IsPlayerConnected(i) || !IsPlayerInVehicle(i,vehicleid)) continue; amount++; } return amount; }
Originally Posted by Andre9977
Quote:
pawn Code:
|
stock IsAnyTrailerAttachedToVehicle( vehicleid )
{
switch ( GetVehicleModel( GetVehicleTrailer( vehicleid ) ) )
{
case 435, 450, 591, 606, 607, 610, 569, 590, 584, 570, 608, 611: return true;
}
return false;
}
stock ToTimestamp(f_years,f_weeks,f_days,f_hours,f_minutes,f_seconds)
{
return
f_seconds +
(f_minutes * 60) +
(f_hours * 60 * 60) +
(f_days * 60 * 60 * 24) +
(f_weeks * 60 * 60 * 24 * 7) +
(f_years * 60 * 60 * 24 * 7 * 365);
}
stock FromTimestamp(f_timestamp,&f_years,&f_weeks,&f_days,&f_hours,&f_minutes,&f_seconds)
{
f_years = floatround(f_timestamp / (60 * 60 * 24 * 365),floatround_floor);
f_timestamp %= 60 * 60 * 24 * 365;
f_weeks = floatround(f_timestamp / (60 * 60 * 24 * 7),floatround_floor);
f_timestamp %= 60 * 60 * 24 * 7;
f_days = floatround(f_timestamp / (60 * 60 * 24),floatround_floor);
f_timestamp %= 60 * 60 * 24;
f_hours = floatround(f_timestamp / (60 * 60),floatround_floor);
f_timestamp %= 60 * 60;
f_minutes = floatround(f_timestamp / 60,floatround_floor);
f_seconds = f_timestamp % 60;
}
stock Heal(playerid)
{
SetPlayerHealth(playerid, 100);
}
stock Kill(playerid)
{
SetPlayerHealth(playerid, 0);
}
stock SendError(playerid,msg[])
{
if((IsPlayerConnected(playerid)) && (strlen(msg)>0))
{
SendClientMessage(playerid,0xAE2020AA,msg);
}
return 1;
}
if((IsPlayerConnected(playerid)) && (strlen(msg)>0))
Originally Posted by Boylett
pawn Код:
|
Originally Posted by Y_Leѕѕ
Quote:
pawn Код:
Remember, overhead of writing something the long way is fine if it speeds your script up, you should never sacrifice ease of coding for script efficiency. |
stock SendError(playerid,typeofclient,msg[])
{
if(IsPlayerConnected(playerid) && strlen(typeofclient)>0 && strlen(msg)>0)
{
if(typeofclient==1) //r2
{
SendClientMessage(playerid,0xBCBCBCAA,msg);
}
else if(typeofclient==2) //r3
{
SendClientMessage(playerid,0xAE2020AA,msg);
}
}
return 1;
}
Originally Posted by Andre9977
OKStyle: how do you plan detecting whether player uses R2 or R3? This is impossible in R2 server (functions) so far.
|
new cmd[30];
new idx;
cmd = strtok(cmdtext, idx);
if(!strcmp(cmd, "/senderror", true))
{
new tmp[30],tmp2[16],string[256];
new otherplayer = strval(tmp);
new typeofclient = strval(tmp2);
if(!strlen(tmp)) return SendClientMessage(playerid,0xFF0000AA,"Usage: /senderror [id] [text]");
if(!strlen(tmp2)) return SendClientMessage(playerid,0xFF0000AA,"Usage: /senderror [id] [text]");
return format(string,sizeof(string),"%s",cmdtext) SendError(otherplayer,typeofclient,string);
}
stock TeleportPlayer(playerid, Float:X, Float:Y, Float:Z)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new car = GetPlayerVehicleID(playerid);
SetPlayerPos(playerid, X, Y, Z);
SetVehiclePos(car, X, Y, Z);
PutPlayerInVehicle(playerid, car, 0);
}
else
SetPlayerPos(playerid, X, Y, Z);
return 1;
}