enum TELE_DATA
{
TELE_CMD[16],
Float:TELE_POS_X,
Float:TELE_POS_Y,
Float:TELE_POS_Z,
TELE_MESSAGE[32],
TELE_WEAPON,
TELE_AMMO,
TELE_MONEY,
TELE_INTERIOR,
TELE_VIRTUAL_WORLD
}
new pTele[][TELE_DATA] =
{
{"/Ramp", 1859.3246, -1381.7324, 13.5625, "!бшелйн дбайн мжйшъ дшофд", 0, 0, 0, 0, 0}
};
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
for(new i, j = sizeof(pTele); i < j; i++)
{
if(strcmp(cmdtext, pTele[i][TELE_CMD], true))
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
SetVehiclePos(GetPlayerVehicleID(playerid), pTele[i][TELE_POS_X], pTele[i][TELE_POS_Y], pTele[i][TELE_POS_Z]);
}
else SetPlayerPos(playerid, pTele[i][TELE_POS_X], pTele[i][TELE_POS_Y], pTele[i][TELE_POS_Z]);
GivePlayerWeapon(playerid, pTele[i][TELE_WEAPON], pTele[i][TELE_AMMO]);
GivePlayerMoney(playerid, pTele[i][TELE_MONEY]);
SetPlayerInterior(playerid, pTele[i][TELE_INTERIOR]);
SetPlayerVirtualWorld(playerid, pTele[i][TELE_VIRTUAL_WORLD]);
SendClientMessage(playerid, -1, pTele[i][TELE_MESSAGE]);
}
}
return 1;
}
CMD:dm1(...)
{
setpos
}
CMD:dm2(...)
{
setpos
}
.
.
etc
.
The for loop is made to make the script check all Tele_CMD of pTele till the right one is found. If it wasnt for the for loop inside OnPlayerCommandPerformed, you would have to:
PHP код:
When do you make Enum+Array? Array can only hold one type of variable when it stands alone.. But with Enum, it becomes flexible.. It can store: Float, Integer, String, Bool, Timer, Text, PlayerText, etc with the help of ENUM. In your case, the Enum makes space inside the Array from 0-15 for string, 16 for Tele_pos_x, etc.. Again, I am just saying it from what I KNOW, and I dont think am good enough to teach others.. Refer: https://sampforum.blast.hk/showthread.php?tid=318307 |
Questions like this are about the underlying PAWN language, and are (mostly) all covered in this document:
pawn-lang.pdf Please read that before asking any more questions. |