All pastes #226116 Raw Edit

CP:Simon

public cpp v1 · immutable
#226116 ·published 2006-10-28 09:37 UTC
rendered paste body
#define WEP_LIMIT   100public OnPlayerCommandText(playerid, cmdtext[]){	new string[256];	new cmd[256];	new idx, weaponid;	cmd = strtok(cmdtext, idx);		// Other stuff - greetz to mabako		// Command - /buyweapon [weapon_id] [weapon_amount]	if(strcmp(cmd, "/buyweapon", true) == 0) {	    new tmp[256];	    new tmp2[256];		tmp = strtok(cmdtext, idx);		tmp2 = strtok(cmdtext, idx);		if(!strlen(tmp) || !strlen(tmp2)) {			SendClientMessage(playerid, COLOR_WHITE, "USAGE: /buyweapon [weapon_number] [weapon_amount]");			return 1;		}		weaponid = strval(tmp);		new ammos = strval(tmp2);		if(IsPlayerInCheckpoint(playerid)==0 || playerCheckpoint[playerid]!=CP_AMMU) {			SendClientMessage(playerid, COLOR_YELLOW, "You need to be in an Ammunation to purchase weapons.");			return 1;		}		if(ammos > WEP_LIMIT || playerWeapons[playerid][weaponid] > WEP_LIMIT || playerWeapons[playerid][weaponid] + ammos > WEP_LIMIT)		{		    format(string, sizeof(string), "The shop refuses to sell anymore weapons to you (Limit: %d).", WEP_LIMIT);		    SendClientMessage(playerid, COLOR_RED, string);		    return 1;		}		if(GetPlayerMoney(playerid) < weaponCost[weaponid]*ammos) {			SendClientMessage(playerid, COLOR_RED, "You don't have enough money!");			return 1;		}		if(weaponid < 0 || weaponid > MAX_WEAPONS-1){			SendClientMessage(playerid, COLOR_RED, "Invalid weapon number.");			return 1;		}		if(ammos < 1)		{		    SendClientMessage(playerid, COLOR_RED, "Invalid weapon amount.");		    return 1;		}		format (string, sizeof(string), "You purchased %d %s's for when you spawn.",ammos,weaponNames[weaponid]);		SendClientMessage(playerid, COLOR_GREEN, string);		GivePlayerWeapon(playerid, weaponIDs[weaponid], weaponAmmo[weaponid]*ammos);		playerWeapons[playerid][weaponid] += ammos;		GivePlayerMoney(playerid, 0-(weaponCost[weaponid]*ammos));		return 1;	}		// Other stuff - greetz to CP}public OnPlayerEnterCheckpoint(playerid){	// Other stuff - greetz to littlewhitey administrators	switch(getCheckpointType(playerid))	{		case CP_AMMU: {			SendClientMessage(playerid, COLOR_GREEN, "You can purchase weapons here so that you have them every");			SendClientMessage(playerid, COLOR_GREEN, "time you spawn. You can purchase more than once for more ammo.");			SendClientMessage(playerid, COLOR_YELLOW, "Type /buyweapon [weapon_number] [weapon_amount] and /weaponlist for a list of weapons.");		}	}	// Other stuff - greetz to everyone else @_@}