09.12.2009, 03:02
For these, you'll need the foreach and zcmd include + sscanf.
Quote:
1. How do I make it so if a player types "/reclass", it sends them into the player class selection? |
Код:
cmd(reclass, playerid, params[]) { ForceClassSelection(playerid); SetPlayerHealth(playerid, 0); return 1; }
Quote:
2. How do I make it so if a play kills another player and the other play is the same skin, it makes the killers score -1 and if it's { else } It makes your score go up 1+ point? |
Код:
new PlayerScore[MAX_PLAYERS]; public OnPlayerConnect(playerid) { PlayerScore[playerid] = 0; return 1; } public OnPlayerDeath(playerid, killerid, reason) { if(GetPlayerSkin(playerid) == GetPlayerSkin(killerid)) { PlayerScore[killerid]--; } else { PlayerScore[killerid]++; } return 1; }
Quote:
3. How would I make it so if a player has - 10,000 dollars, the player is kicked, it sends a message saying you have been kicked due to debt, and it sends a message to the other players saying that person was kicked due to being in debt. |
Код:
new kicktimer; public OnGameModeInit() { kicktimer = SetTimer("KickForDebt", 5000, 1); return 1; } public OnGameModeExit() { KillTimer(kicktimer); return 1; } public KickForDebt() { foreach(Player, x) { if(GetPlayerMoney(x) <= -10000) { SendClientMessage(x, 0xFF000000, "You have been kicked for being in excessive debt."); Kick(x); } } return; }
Quote:
4. Anyone know the scripting code to add a /pm command into your server? |
Код:
cmd(pm, playerid, params[]) { new sentto, message[128]; if(sscanf(params, "us", sentto, message)) return SendClientMessage(playerid,0xFF0000FF,"USAGE: /PM (id) (message)"); if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0xFF000000,"Invalid ID"); new string[128], sender[MAX_PLAYER_NAME], target[MAX_PLAYER_NAME]; GetPlayerName(playerid, sender, sizeof sender); GetPlayerName(sentto, target, sizeof target); format(string, sizeof(string),"You tell %s(%i): %s", target, sentto, message); SendClientMessage(playerid, 0x4EEE9400, string); format(string, sizeof(string), "%s(%i) says: %s", sender, playerid, message); SendClientMessage(id, 0x4EEE9400, string); PlayerPlaySound(id,1085,0.0,0.0,0.0); return 1; }