This thread was created for newbies to browse tips/tricks shared by experienced scripters. |
Tip/Trick Title: Tip/Trick Description: Tip/Trick Example(Use PAWN tags): |
#include <a_samp>
forward SpawnKillTimer(playerid);
public OnPlayerSpawn(playerid)
{
SetTimerEx("SpawnKillTimer", 5000, false, "i", playerid);
GameTextForPlayer(playerid, "~r~anti-spawn-kill 5 seconds", 5000, 6);
SetPlayerHealth(playerid, 9999999);
return 1;
}
public SpawnKillTimer(playerid)
{
SetPlayerHealth(playerid, 100);
GivePlayerWeapon(playerid, 24, 500);
GameTextForPlayer(playerid, "~r~anti-spawn-kill over", 5000, 6);
return 1;
}
I am sure there is a topic like this made by Slice, if I am not wrong!
|
Sorry for the replies in quick succession!
The link: https://sampforum.blast.hk/showthread.php?tid=216730 |
enum pEnum {
bla, ble, bli, blo, blu
}
main() {
new arr[pEnum];
arr[bla] = 00;
arr[bli] = 10;
arr[blu] = 20;
printf( "%d - %d - %d",
arr[bla], arr[bli], arr[blu]
);
for( new i ; i != _: pEnum; i++) {
arr[pEnum:i] = _: 0;
}
printf( "%d - %d - %d",
arr[bla], arr[bli], arr[blu]
);
}
enum pEnum {
bla, ble, bli, blo, blu
}
main() {
new arr[pEnum];
arr[bla] = 00;
arr[bli] = 10;
arr[blu] = 20;
printf( "%d - %d - %d",
arr[bla], arr[bli], arr[blu]
);
new reset[pEnum];
arr = reset;
printf( "%d - %d - %d",
arr[bla], arr[bli], arr[blu]
);
}
for(new x; str[x]; x++) {
}
if( var1 == 0 && var2 == 0 && var3 == 0)
if( var1 | var2 | var3 == 0)
//enum to record the variables in
enum pInfo
{
Float:pPosX,
Float:pPosY,
Float:pPosZ,
Float:pPosR,
}
new PlayerInfo[MAX_PLAYERS][pInfo];
//actually function
public OnPlayerDeath(playerid, killerid, reason)
{
GetPlayerPos(playerid, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
GetPlayerFacingAngle(playerid, PlayerInfo[playerid][pPosR]);
//Respawn at the place of death
SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ], PlayerInfo[playerid][pPosR], 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
return 1;
}
enum debug//Enumerator
{
debug1, debug2, debug3, debug 4;
}
new debug[ MAX_PLAYERS ][ debug ];
CMD:setenumto1(playerid, params[]) // debug purposes
{
debug1[playerid][debug1] = 1;
debug1[playerid][debug2] = 1;
debug1[playerid][debug3] = 1;
debug1[playerid][debug4] = 1;
printf("[DEBUG]: %i, %i, %i, %i", debug1, debug2, debug3, debug4);
//DEBUG result ( [DEBUG]: 1, 1, 1, 1)
}
//new process | shorter version
CMD:resetenum(playerid, params[])
{
for(new i; robbingshop:i < robbingshop; i++) { debug[ playerid ][ robbingshop:s ] = 0; } return 1;
printf("[DEBUG]: %i, %i, %i, %i", debug1, debug2, debug3, debug4);
//DEBUG result ( [DEBUG]: 0, 0, 0, 0 )
}
//instead of | longer version
CMD:resetenum1(playerid, params[])
{
debug1[playerid][debug1] = 0;
debug1[playerid][debug2] = 0;
debug1[playerid][debug3] = 0;
debug1[playerid][debug4] = 0;
printf("[DEBUG]: %i, %i, %i, %i", debug1, debug2, debug3, debug4);
//DEBUG result ( [DEBUG]: 0, 0, 0, 0 )
}